Hi all, I learning Java as a second language. And I found some syntax in my book of android development to be very hard to explain. Would you help me with this example :

Button btn(Button)findViewById(R.id.btn_dialog);
btn.setOnClickListener(new View.OnClickListener(){
public void OnClick(View v) {

Its quite different from c++,you create View object and then you are calling OnclickListener or overloading it? I assume its overloading, but then it should go statments defining the method and here is another function with different name and that name it seams gets overloaded. Would you explain what's is really going on.
thank you

Edited by cppgangster: n/a

6 Years
Discussion Span
Last Post by cppgangster

its an anonymous internal(inner) class, wikipedia didn't have a very helpful description for those but i think this article explains them pretty well, i didn't read it all but from the diagonal sampling i did it looks complete :P

anonymous inner class

Edited by Philippe.Lahaie: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.