Is it possible to show a FragmentDialog when a tab is selected in the ActionBar?
The onTabSelected() method happens inside a transaction that is commited after the execution of the method finishes. However, the show() method in DialogFragment does also happen in a transaction automatically, so if you try to show the dialog when the tab is selected you get a RuntimeException because the transaction gets commited twice.
Any hints will be appreciated.
Just ignore the supplied
FragmentTransaction.For example, you need to do this if you are using the Android Compatibility Library (ACL), because the
FragmentTransactionyou get from the action bar is an Android 3.0FragmentTransaction, not an ACLFragmentTransaction. So, you ignore the passed-in one and use your own.Similarly, I would expect that you can ignore the
FragmentTransactionand display aDialogFragmentyourself without problems.Whether the UX will make any sense is another problem. When the user accepts the dialog the tab shows… nothing?