Footer in Tabbed Activity

389 views Asked by At

I am using Tabbed Activity and I have three tabs with corresponding fragments. Now I want to dispay a footer that displays on every fragment when I change the Tab. Is this possible?? Please give me an simple example

1

There are 1 answers

0
Karthik Sridharan On BEST ANSWER

Footer layout u will paste into Tabbed activity layout below tab host xml

like

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

    </TabHost>
    <LinearLayout
        android:id="@+id/footer"
        android:layout_below="@android:id/tabs"
        android:layout_alignParentBottom="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

    </LinearLayout>
</RelativeLayout>

After that change view in footer based on tab selection using like this

tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
            @Override
            public void onTabChanged(String s) {
                //Add view into footer or hide 
            }
        });