Nested ViewPager not displaying

887 views Asked by At

I am writing an application where used Nested ViewPager. Every Parent ViewPager contain 7 child ViewPager.

It work properly for first parent, but when it reached to next Page it show blank at place of child Viewpager.

Any suggestion here, if it's feasible to use Nested View pager even? and if it is How can I avoid this case?

Parent ViewPager Layout and same as Child Fragment:

<FrameLayout
                xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:customfont="http://schemas.android.com/apk/res-auto"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >

                <android.support.v4.view.ViewPager
                    android:id="@+id/calendarViewPager"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >
                </android.support.v4.view.ViewPager>

and this is Child ViewPager Adapter implementation that I am doing from Parent ViewPager Fragment:

private void processDatacardAdapter(View view) {

        childViewPager = (ViewPager) view.findViewById(R.id.childViewPager);

        childSlidePagerAdapter = new ChildSlidePagerAdapter(parentActivity.getSupportFragmentManager());

        childViewPager.setAdapter(childSlidePagerAdapter);

        childViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
            @Override
            public void onPageSelected(int position) {

                Utils.showToast(parentActivity, "sds position : " + position);

            }
        });
    }
1

There are 1 answers

2
CoDe On BEST ANSWER

Change FragmentManager work for me: Change

new ChildSlidePagerAdapter(parentActivity.getSupportFragmentManager());

by

new ChildSlidePagerAdapter(getChildFragmentManager());