开发者

cancelListener vs keyListener

I want dismissDialog(ID) to be called whenever dialog is gone (disapears, get clos开发者_StackOverflowed , ...), so it may happen when user press BACK button or any other scenario that may close the dialog.

which one is better approach? to call onCancelListener on dialog? or call OnKeyListener and assign if (keyCode == KeyEvent.KEYCODE_BACK) // do smth

thanks.


Use onBackPressed(), to do cleanup or whatever you want to do in dismissdialog()


if you do not ant to allow to dialog disappear,when back button pressed.it can be done by setting dialog's property as below:


dialog.setCancelable(false);//here dialog is object of Dialog class which you want to show
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜