开发者

How to dismiss the dialog only not the activity which calling that dialog on press of back key?

I am populating a dialog which is having a tab view from an activity. Tab view start different activity on clicking different tab with the help of different intent. If i press back key, activity which is calling dialog is also getting dismissed with dialog. But on press of back key i just wnat to dismiss the dialog not the calling activity. how 开发者_运维问答to do that?


Override the setOnCancelListener of the dialog or the activity onBackPressed depending on your application. Post your code for more accurate awnsers.


Just use the dialog.dismiss() method.


there is a default method present in android 2.1 and above called onBackButtonPressed(). it is a part of the activity class.... so in that method just do the following:

dialog.dismiss();

this will not do anything else.. but just close the dialog.


ProgressDialog dialog = ProgressDialog.show(context, "Venues", "Loading...", true, true,     new OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            dialog.dismiss();
        }
    } );
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜