I have two buttons like this:
btnSurPlace.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
v.setPressed(true);
// show interest in events resulting from ACTION_DOWN
if (event.getAction() == MotionEvent.ACTION_DOWN) return true;
// don't handle event unless its ACTION_UP so "doSomething()" only runs once.
if (event.getAction() != MotionEvent.ACTION_UP) return false;
onPlace = true;
btnEmporter.setPressed(false);
return true;
}
});
btnEmporter.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// show interest in events resulting from ACTION_DOWN
if (event.getAction() == MotionEvent.ACTION_DOWN) return true;
// don't handle event unless its ACTION_UP so "doSomething()" only runs once.
if (event.getAction() != MotionEvent.ACTION_UP) return false;
onPlace = false;
v.setPressed(true);
btnSurPlace.setPressed(false);
return true;
}
});
The problem is that in the activity I open a dialogue made with an Activity
<activity
android:name=".MenuDialog"
android:theme="@android:style/Theme.Holo.Light.Dialog.NoActionBar.MinWidth" />
When you open such Dialog, the selected button is deselected.
How can I make the button that the person selected, keep selected even after opening and closing the Dialog.