From that I\'ve read you can assign a onClick
handler to a button in two ways.
Using the android:onClick
XML attribute where you just use t
To make your life easier and avoid the Anonymous Class in setOnClicklistener (), implement a View.OnClicklistener Interface as below:
public class YourClass extends CommonActivity implements View.OnClickListener, ...
this avoids:
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
yourMethod(v);
}
});
and goes directly to:
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.your_view:
yourMethod();
break;
}
}