문제

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