Here I am showing a Here is my code for this AlertDialog by pressing a menu key and displaying its popup
dialog But when I'm trying to
, pressing the menu key again for another does not trigger the
menu key .
@SuppressLint ({"NewApi", "NewApi", "NewApi", "NewApi"}) @Override Public Boolean OnKeyDown (Integer keycode, keyEvent event) {AlertDialog.Builder alertDialogBuilder = New AlertDialog.Builder (reference); If (keycode == KeyEvent.KEYCODE_MENU and event.getAction () == 0) {if (open!) {ShowDialogItem (); Open = true} Else if (open) {alertDialog.dismiss (open = false;} return true;} super.onKeyDown Return (keycode, event);} Public Zero showDialogItem () {AlertDialog.Builder alertDialogBuilder = New AlertDialog.Builder Reference); Vigilant DLObuilder.setItems (R.ra.Salt_LiOG_Intems, New Dialogue Interface.OnclickList () {click on Public Zero (Dialogue Interface Dialog, Int J) {String [] items = Reset (). GetStringArray (R. Night.Salte_pilog_iites); New AlertDialog. Builder (MainActivity.this ) .setMessage ("you selected:" + + [which]] .show ();}}); alertDialog = alertDialogBuilder.create (); WindowManager.LayoutParams LP = new WindowManager. LayoutParams (); LP = alertDialog.getWindow () getAttributes (); lp.gravity = Gravity.TOP | Gravity.LEFT ;. lp.x = -300; lp.gravity = Gravity.BOTTOM; alertDialog.getWindow () SetAttributes. (LP); Sarkshmilog.show (); AlertDialog.GateVundo () Set Layout (130, 220);}
got started this started public static x = 0; Public boolean OnKeyDown (int keycode, KeyEvent event) {if (keycode == KeyEvent.KEYCODE_MENU & amp; & amp; event.getAction () == 0) {AlertDialog.Builder builder = new AlertDialogkBuilder (it) KsetOnKeyListener ( new DialogInterface .OnKeyListener () {@Override public boolean onKey (DialogInterface dialog, int keycode, KeyEvent event) {if (keycode == KeyEvent.KEYCODE_MENU & amp; & amp; event.getAction () == 0) {if (x == 1) {Alert.dismiss (); x = 0;} Veracity back;} return false;}}); If (x == 0) {builder.setmesge ("login details changed successfully ..."); Builder. Set reject (true); Builder.setPositiveButton ("OK", New DialogInterface.OnClickListener () {Click Public Zero (DialogInterface Dialog, Ent ID) {System.exit (0);}}); Alert = builder.create (); Alert.show (); X = 1; } Back true; }
No comments:
Post a Comment