1

There is a tabhost that contains 3 elements. How to make swipe between them?

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </TabWidget>

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

        <LinearLayout
            android:id="@+id/tab1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >

            <android.support.v7.widget.RecyclerView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/tasks1">
            </android.support.v7.widget.RecyclerView>
        </LinearLayout>

        <LinearLayout
            android:id="@+id/tab2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >

            <android.support.v7.widget.RecyclerView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/tasks2" >
            </android.support.v7.widget.RecyclerView>
        </LinearLayout>

        <LinearLayout
            android:id="@+id/tab3"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >

            <android.support.v7.widget.RecyclerView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/tasks3">
            </android.support.v7.widget.RecyclerView>
        </LinearLayout>
    </FrameLayout>
</LinearLayout>

</TabHost>

If you alter this option does not work, then how to do this with a tabbed activity(i need to swipe between the 3 elements)? Thanks in advance.

Jaive
  • 51
  • 1
  • 10
  • I would use a ViewPager rather than a FrameLayout. Refer to the official documentation/tutorial for more info http://developer.android.com/training/implementing-navigation/lateral.html – Jace J McPherson May 03 '16 at 23:27
  • Just a suggestion, using a TabLayout with a ViewPager will be much easier to implement, see here: http://stackoverflow.com/questions/34579614/how-to-implement-recyclerview-in-a-fragment-with-tablayout And for using a CoordinatorLayout and some of it's features, see here: http://stackoverflow.com/questions/35967941/whatsapp-like-collapsing-toolbar – Daniel Nugent May 04 '16 at 01:48

0 Answers0