I have a main tab activity where i have two tabs, the tab position are below the layout, I want the tab positions below the actionbar like in google play and when i move from one tab to another tab, the data shows from previous tab even though i set saveEnabled to false. Here is my code
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Reusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
// Do the same for the other tabs
intent = new Intent().setClass(this, RunningOrder.class);
spec = tabHost.newTabSpec("runningOrder")
.setIndicator("Running Order", res.getDrawable(R.drawable.running_order))
.setIndicator("Running Order")
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, OrderHistoryTab.class);
spec = tabHost
.newTabSpec("orderHistory")
.setIndicator("Order History",
res.getDrawable(R.drawable.history_icon))
.setContent(intent);
tabHost.addTab(spec);
//set tab which one you want open first time 0 or 1 or 2
tabHost.setCurrentTab(0);
And this is my xml layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical" >
<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:saveEnabled="false"
android:layout_height="fill_parent"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:saveEnabled="false"
android:layout_weight="1"/>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:textAlignment="textStart"
android:saveEnabled="false"
android:layout_marginBottom="-4dp"/>
</LinearLayout>
for making tab position below of the action bar swap frameLayout and tabWidget position.
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:textAlignment="textStart"
android:saveEnabled="false"
android:layout_marginBottom="-4dp"/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:saveEnabled="false"
android:layout_weight="1"/>