I\'m a beginner to android, while setting onclick listener to a button, what does the parameter passed mean:
btn1.setOnClickListener(new OnClickListener() {
OnClickListener
is an interface. It means if you set it inline you have created an anonymous class which is just implimenting the interface inside the set method.
If you wanted to create an OnClick
class. You would do something like this:
class OnButtonClick implements OnClickListener{
public void onClick(View v) {
// TODO Auto-generated method stub
}
}
Then you can use:
OnButtonClick obc = new OnButtonClick();
textView.setOnClickListener(obc);
This is more Java than android, Read about Interfaces and Inner Classes