Dismiss non-cancelable dialog on fragment backPress - Android -
i have navigation drawer activity , many fragments reach via nav drawer.
in of these fragments, show dialog says "loading.." while background tasks happening.
now i've made dialogs not-cancellable dialog.setcancelable(false)
user doesn't accidentally dismiss clicking anywhere on screen. makes un-cancelable when phone button pressed.
this code dialog -
dialog dialog = new dialog(context); dialog.requestwindowfeature(window.feature_no_title); dialog.setcontentview(r.layout.custom_progress_dialog); ((textview)dialog.findviewbyid(r.id.custom_dialog_message)).settext("loading ..."); dialog.setcancelable(false); dialog.show();
i need write code dismiss loading dialog , go previous fragment when phone button pressed while on fragment.
can me out? need implementing backpress specific fragment. thanks!
you can use getfragmentmanager().popbackstackimmediate();
dialog.setonkeylistener(new dialog.onkeylistener() { @override public boolean onkey(dialoginterface dialog, int keycode, keyevent event) { // todo auto-generated method stub if (keycode == keyevent.keycode_back) { dialog.dismiss(); getfragmentmanager().popbackstackimmediate(); } return true; } });
Comments
Post a Comment