Java – using dialogs in fragments

In my application, I have an activity and several fragments (activity as controller and fragments – as view)

In some clips, I need to display alertdialogs and progressdialogs. Activity can change the current clip

My problem is: the activity can receive broadcast and C2DM notifications. When I create an alertdialog, the activity can change the fragment, but the dialog will remain Therefore, when the user clicks some buttons, the application crashes

Dialogfragments is like a simple dialog

Do I manually close the dialog box or check if the clip is active? Is there a built-in tool?

Solution

First of all, I may miss something, no code, etc., but

Second: maybe you shouldn't use dial-up? It looks like a cumbersome user interface Use clips only for these? Although you said you were using dialog fragments, you may have considered them and used them as "regular" fragments

Third: when the displayed clip is deleted / hidden, close the dialog box? For example, using the onstop() callback at a clip or more central location, you may be saving the currently displayed clip and deciding to display a new clip Close the dialog box by calling "dismiss" on the Dialog object or calling Fragment or dismissDialog in Activity.

See release dialog box: http://developer.android.com/guide/topics/ui/dialogs.html#DismissingADialog

You can still call dismis. On these dialogfragments http://developer.android.com/reference/android/app/DialogFragment.htm

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>