android backbutton in fragment calling 2 times -
Text after "div class =" itemprop = "text">
In one of my apps, I think the key is to provide the exit dialog on pressing the back key.
Code LogCat: The problem is that it is saying 2 times ... what is happening to it This attempt for the code
View View = inflater.inflate (R. Late Fragment_Layout1, blank); view.setFocusableInTouchMode (true); View.requestFocus (); View.setOnKeyListener (New OnKeyListener) {@Override Public Boolean onKey (see arg0, integer keycode, keyEvent ARG2) {Log.i ("tag", "keycode:" + keycode); if (keycode == KeyEvent.KEYCODE_BACK) {Log.i ("tag", "onKey back listener is working !!!"); // getFragmentManager () popBackStack (Zero, FragmentManager.POP_BACK_STACK_INCLUSIVE); return true;} else {return false;}}} );
04-22 November: 40: 53.291: me / tag (31,150): encoded: 4 04 -22 11: 40: 53.291: I / Tag (31150): OK back listener is working !!! 04-22 11: 40: 53.351: I / Tag (31150): Keycode: 4 04-22 11: 40: 53.351: I / Tag (31150): OK back listeners are working !!!
@Override Public Boolean OnKeyDown (integer keycode, KeyEvent event) {if ((encoded == KeyEvent.KEYCODE_BACK)) {AlertDialog. Builder Alertbox = New AlertDialog .Builder (previousEntry.this); alertbox.setTitle ("Do you want to exit?"); Alertbox.setPositiveButton ("Yes", New DialogInterface.OnClickListener () {Click on Public Zero (DialogInterface arg0, int arg1) {// Finish to finish the activity used to end ();}}); Nothing will be done when clicking on Alertbox.setNegativeButton ("No", New DialogInterface.OnClickListener () {Public Zero (DialogInterface arg0, int arg1) // // Click any button of dialog;); Alertbox.show (); } Return super.Condondon (keycode, event); }
Comments
Post a Comment