Reputation: 11
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?
Upvotes: 1
Views: 542
Reputation: 746
ProgressDialog dialog = ProgressDialog.show(context, "Venues", "Loading...", true, true, new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
dialog.dismiss();
}
} );
Upvotes: 1
Reputation: 11765
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.
Upvotes: 1
Reputation: 1133
Override the setOnCancelListener
of the dialog or the activity onBackPressed
depending on your application. Post your code for more accurate awnsers.
Upvotes: 1