Android – prevent Dialog to be cashed in the Activity – Mea Cup O' Jo
Skip to content


Android – prevent Dialog to be cashed in the Activity

If you override Activity#onCreateDialog method to create a pop-up dialog something that you have to be aware is this dialog will be cashed for any subsequent calls. For most cases it is just the right behavior but what if you want to change contents of the dialog on the next call? One possible scenario – say you have few tabs that display similar content in the same pop-up but the info changes based on the active tab. Here’s one way to do it. When you set your onClick listener put this into onClick call:
dialog.dismiss();
activity.removeDialog(DIALOG_ID);

Here DIALOG_ID is the same ID you are using in the Activity#onCreateDialog call

Posted in Android, Programming.

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.