I currently have a button which is setPressed(true) on an app i'm creating. I also have an AlertDialog box appear when I press the back button. I noticed that when I press the back button and the AlertDialog box appears the button I have set pressed to true changes to false. I can't understand what is causing this as there is nothing in my code to tell the button to change setPressed to false. I can supply my code if anyone wishes but I believe something else causes this. Any help would be hugely appreciated. :)
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
exitByBackKey();
return true;
}
return super.onKeyDown(keyCode, event);
}
protected void exitByBackKey() {
if(!instOn){
if(toast != null)
toast.cancel();
AlertDialog alertbox = new AlertDialog.Builder(this).setMessage("Do you want to exit?")
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
finish();
System.exit(0);
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
// do something when the button is clicked
public void onClick(DialogInterface arg0, int arg1) {
if(!stage1 || !stage2){
button3.setClickable(false);
button3.setPressed(true);
}
}
})
.setNeutralButton("Restart", new DialogInterface.OnClickListener() {
// do something when the button is clicked
public void onClick(DialogInterface arg0, int arg1) {
newGame();
}
})
.show();
//alertbox.setCancelable(false);
}
else{
instOn = false;
trans.transition.reverseTransition(800);
popupWindow.dismiss();
button1.setClickable(true);
button2.setClickable(true);
soundButton.setClickable(true);
}
}