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) {
showDialog(0);
}
});

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

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

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.