Android viewpager in fragment

Ladies and gentlemen,

First of all, please do not pose my question. If you think my question is too stupid, let me know and I will edit or delete it.

So my actual question is that I have activity ( extends Activity). In this action layout I created FrameLayoutwhere I then added four different fragments (so each of them extends Fragment. Therefore, in one of these fragments I would like to use swipeable tabs (see screenshot).

I know that this is usually done by implementing viewPager and FragmentPagerAdapter, but I cannot do it as if I were calling getSupportFragmentManagerin my fragment, it gives me an error. If I use getActivity().getFragmentManager(), it gives me an error that android.support.v4.app.fragmentmanager cannot be applied to android.app.fragmentmanager . I have to use android.support.v4.app.fragment in my fragment, because otherwise I will not be able to realize my kind of activity (described at the beginning).

Any ideas or suggestions would be greatly appreciated. screenshot

0
source share
3 answers

, Fragment, , . FragmentActivity getSupportFragmentManager();

, viewpager, , , , getChildSupportFragmentManager();

" ".

PS: , AppCompatActivity FragmentActivity. FragmentActivity ActionBarActivity .

.

+2

getChildFragmentManager() .

0

v4 (Android 4.2) . FragmentPagerAdapter :

public CustomFragmentPagerAdapter(android.support.v4.app.Fragment fragment)
{
    super(fragment.getChildFragmentManager());

    // write your code here
}

, Android

0
source

All Articles