问题
I am converting my app to use the v4 compatibility package and fragments. I have done well so far, but I need to launch a DialogFragment from a preference click in a PreferenceActivity
. Since there isn't a PreferenceFragment in the compatibility library, I'm stuck with using PreferenceActivity
. Is it possible to get a reference to the fragment manager and call the DialogFragment
or do I just have to continue using the old dialog if I need a dialog from a preference?
回答1:
Not without jumping through hoops.
You could make a very simple activity with the sole purpose of launching the DialogFragment. If you do this you will need to finish() that activity when the DialogFragment dialog has been dismissed.
来源:https://stackoverflow.com/questions/7922906/is-it-possible-to-launch-a-dialogfragment-from-a-preference-in-a-preferenceactiv