Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Nested Tabs #310

Open
gsus24 opened this issue Feb 10, 2021 · 0 comments
Open

Nested Tabs #310

gsus24 opened this issue Feb 10, 2021 · 0 comments

Comments

@gsus24
Copy link

gsus24 commented Feb 10, 2021

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant