Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ViewPager, getChildFragmentManager() & getFragmentManager()

I'm developing an android app, with TabHost & FragmentActivity in each tab.

In my first tab I initialize a fragment with a ViewPager indicator and a button, this button open a dialog with another ViewPager indicator, but my problem is the ViewPager in the fragment root activity is clashing with the ViewPager's dialog.

In the root activity I'm calling getChildFragmentManager()... and is OK but in the dialog ViewPager I'm calling again getChildFragmentManager but not working...

What am I doing wrong?

like image 809
Ollie Strevel Avatar asked Oct 07 '13 18:10

Ollie Strevel


People also ask

What is getChildFragmentManager?

getSupportFragmentManager and getChildFragmentManager FragmentManager is class provided by the framework which is used to create transactions for adding, removing or replacing fragments.

How do you get ViewPager fragments?

ViewPager save Fragment in FragmentManager with particular tags, So We can get ViewPager's fragment by FragmentManager class by providing tag. And ViewPager provide tag to each fragment by following syntax : Fragment page = getSupportFragmentManager(). findFragmentByTag("android:switcher:" + R.


1 Answers

I think the dialog is independent from the fragments so try getFragmentManager() or if you are using support library use getSuportingFragmentManager()

like image 163
youssefhassan Avatar answered Oct 05 '22 08:10

youssefhassan