So what's the difference between setting a button listener like this :
private OnClickListener myButtonListener = new OnClickListener() {
@Override
public void onClick(View v) {
//do stuff
}
}
And putting the name of a method on android:onclick attribute-
android:onClick="onClickMyButton"
Then in the activity class add the said method.
public void onClickMyButton(View v) {
// do stuff
}
Most pieces of code I've seen use the first approach, I tend to use the latter, is there any difference ?