java - Up Navigation Confirmation -
i have score keeping application in parent activity allows user enter custom team names.

the user can keep score during game.

should user hit button while in score keeping activity (to return team selector activity), i've implemented confirmation due loss of scoring data:
@override public void onbackpressed() { new alertdialog.builder(this) .seticon(android.r.drawable.ic_dialog_alert) .settitle("return team selector") .setmessage("returning team selector reset scores. sure " + "you want continue?") .setpositivebutton("yes", new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { finish(); } }) .setnegativebutton("no", null) .show(); } i'd implement similar confirmation when the user "up navigates" parent (i.e., team selector) since there same loss of scoring data. however, i've run problems doing so.
is there analogous "onuppressed" function i'm failing find? other guidance on how might solve appreciated.
yes can it...
@override public boolean onoptionsitemselected(menuitem item) { switch (item.getitemid()) { case android.r.id.home: onbackpressed(); } return super.onoptionsitemselected(item); }
Comments
Post a Comment