LL.bindClass(“android.widget.Button”);
LL.bindClass(“android.widget.Button”);
LL.bindClass(“android.view.View”);
var mctx = LL.getContext();
var mButton = new Button(mctx);
mButton.setOnClickListener(new View.OnClickListener(){
onClick:function(View mButton){
Android.makeNewToast(“Hello World”, false).show();
}
});
return mButton;
Error: At Line 10 ) missing after formal parameters (onClickButton#10)
Im playing with custom views and failing 🙁 can any one tell me what I did wrong I think its my OnClick function but I don’t really know how to translate java to js and the android dev docs are kinda hard to read for me so theres probably something else wrong lol cheers.
]]>
< ![CDATA[
Did you bind android.view.View?
]]>
< ![CDATA[
Yeah i did my bad i forgot about that i wrote this from memory its not a straight copy and paste, when I get back to my tab in about half hour I’ll copy and paste/replace this^ with my actual code and error message
That reminds me it would be cool if we could select and copy text from the error dialog Pierre Hébert
]]>
< ![CDATA[
Edited^ I tried fixing it by doing what the error said but still don’t work.
]]>
< ![CDATA[
Replace the line
onClick:function(View mButton){
with
onClick:function(view){
]]>
< ![CDATA[
Works 🙂 thanks the android docs are difficult to understand it says that the OnClick parameter is the view that was clicked I thought that would of been my button.
]]>
< ![CDATA[
This can be your button (in this code this will only be your button) but you could reuse the same listener for several button, for instance this way:
var btn1 = new Button(context);
var btn2 = new Button(context);
var btn3 = new Button(context);
var listener = new View.OnClickListener(){
onClick:function(view){
if(view == btn1) {
// do something for btn1
} else if(view == btn2) {
// do something for btn2
} else if(view == btn2) {
// do something for btn2
}
}
};
btn1.setOnClickListener(listener);
btn2.setOnClickListener(listener);
btn3.setOnClickListener(listener);
This is slightly more efficient and can be used to factor code.
]]>
< ![CDATA[
I wouldn’t say the docs are difficult to understand but you need to catch the mindset. When I started to write android apps, I was really disoriented because it was different of what I was used to, but like everything else with a bit of practice it becomes easier 🙂
]]>
< ![CDATA[
Thanks for the explanation think I can also figure out how to use a switch and case from that, what about the error dialog text selection is that possible to implement? We could just screenshot it but you can’t attach pics to comments on g+ so this would be a handy feature to have.
]]>
< ![CDATA[
This is a smart idea, but at the moment I cannot afford this extra effort.
]]>
< ![CDATA[
No probs 🙂
]]>
< ![CDATA[
Pierre Hébert OT: How did you get the idea to write a launcher? Because your other apps seem to be of a completely different genre.
OT 2: Why are the old plugins (e. g. Locker) still visible in Play Store? Aren’t they integrated anyway?
]]>
< ![CDATA[
Because I needed a launcher… The app had different goals at that time.
The plugin is still here because it does no harm (it is still usable and the lock screen is not available in older free versions)
]]>