Button
has a setPressed
method which you could use in one of the buttons onClickListener
to set the other button to a pressed state. You could then set an OnTouchListener
on that button and listen for MotionEvent.ACTION_UP to set it back to a non pressed state.
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
button2.setPressed(true);
}
});
button.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP)
button2.setPressed(false);
return false;
}
});