質問

I created 2 DialogFragments, the first one is created in onCreateDialog() where I only set an adapter, I don't set any view. When the user selects a list items in the dialog I would like to replace the content of the dialog between the title and the buttons with another DialogFragment, I tried many things and searched a lot but didn't come across something like I'm needing.

役に立ちましたか?

解決

So this took me a lot of digging to figure out.

DialogFragment's show method only adds fragments hence if you want to replace them you have to manually remove the previous dialog fragment.

One thing to keep in mind, it is important to use the same fragmentManager used to open the initial DialogFragment. For example if you opened the first DialogFragment via an Activity (supportFragmentManager) and now using the DialogFragment's fragment manager (childFragmentManager) since they do not have the same stack you wont be able to access the original DialogFragment and remove it.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top