Skip to content

Nested Tabs #310

@gsus24

Description

@gsus24

Hello
try to create double layer tabs. Each tab of the first layer should contain new tabs.
Started with the icon/text example and create the first tab layer in Activtiy like in the example.
In the first Fragment .inflate() a new layout in onCreate(), same as the acitvity_demo but without the toolbar and

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

    <LinearLayout
        android:id="@+id/header2"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/primary"
        >

        <FrameLayout
            android:id="@id/tab2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            />

    </LinearLayout>

    <androidx.viewpager.widget.ViewPager
        android:id="@id/viewpager2"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/header2"
        />

</RelativeLayout>

In the first Fragment set the ViewPager like in the example but to my nested layout

Demo demo = getDemo();
            ViewGroup tab = (ViewGroup) view.findViewById(R.id.tab2);
            tab.addView(LayoutInflater.from(getActivity()).inflate(demo.layoutResId, tab, false));

            ViewPager viewPager = (ViewPager) view.findViewById(R.id.viewpager2);
            SmartTabLayout viewPagerTab = (SmartTabLayout) view.findViewById(R.id.viewpagertab);
            demo.setup(viewPagerTab);

            CharSequence[] tabs = {"Effects", "Transform"};
            FragmentPagerItems pages = new FragmentPagerItems(getActivity());
            for (int i=0; i<tabs.length; i++) {
                pages.add(FragmentPagerItem.of(tabs[i], RemoteNestedFragment.class));
            }

            FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
                    getActivity().getSupportFragmentManager(), pages);

            viewPager.setAdapter(adapter);
            viewPagerTab.setViewPager(viewPager);

Finally i want to create a ListView

lView = (ListView) view.findViewById(R.id.androidList);
            lAdapter = new ListAdapter(getActivity(), version, versionNumber, images);
            lView.setAdapter(lAdapter);
            lView.setOnItemClickListener(this);

Without the second tab layer it works great, but with the second one the ListView doesn´t appear,
What i am doing wrong? Or is it impossible with multilayer tabs?

Thanks, cheers

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions