I would rather go for the click handling in code than using the onClick
attribute in xmlXML when working with fragments.
This
This becomes even easier when migrating your activities to fragments. You can just call the click handler (previously set to android:onClick
in xmlXML) directly from each case
block.
findViewById(R.id.button_login).setOnClickListener(clickListener);
...
OnClickListener clickListener = new OnClickListener() {
@Override
public void onClick(final View v) {
switch(v.getId()) {
case R.id.button_login:
// whichWhich is supposed to be called automatically in your
// in your activity, which has now changed to a fragment.
onLoginClick(v);
break;
case R.id.button_logout:
...
}
}
}
When it comes to handling clicks in fragments, this looks simpler to me than android:onClick
.