yesterday I noticed the possibility to integrate Fragments in older API Levels through the Compatibility package, but thats not really essential for the question. :)
Another solution is to extend Button
and override setPressed(boolean pressed)
method so you can handle platform calls from the onClickEvent
using a flag, for example changing the boolean pressed parameter depending on your needs.
public class MyButton extends Button {
boolean isSelected = false; //this is your flag
@Override
public void setPressed(boolean pressed) {
if(isSelected) {
//here you change the parameter so it stays pressed
super.setPressed(true);
return;
}
super.setPressed(pressed);
}
public void setIsSelected(boolean selected) {
this.isSelected = selected;
}
public MyButton(Context context) {
super(context);
}
}