I want fixed tabs at bottom such I can use the same tabs in each activity. I have a layout that shows the tabs at bottom but how can I add TextView above of that?
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabHost = getTabHost();
TabHost.TabSpec tabSpec;
Intent intent;
Resources resources = getResources();
intent = new Intent(MainActivity.this, FirstActivity.class);
tabSpec = tabHost.newTabSpec("tab1");
tabSpec.setContent(intent);
tabHost.addTab(tabSpec);
intent = new Intent(MainActivity.this, SecondActivity.class);
tabSpec = tabHost.newTabSpec("tab2");
tabSpec.setContent(intent);
tabHost.addTab(tabSpec);
}
This is my TabActivity. And I have ThirdActivity whose layout is like that(It does not seem but TextView is in RelativeLayout) :
<?xml version="1.0" encoding="UTF-8"?>
TextView
android:id="@+id/text"
android:gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
And I want ThirdActivity should contain the tabs “tab1” and “tab2”.
Use the tutorial in link above posted by Dipak, to create the layout of the TabHost.
Then go ahead an create a class to handle the TabActivity and create 3 separate activity classes for each of your tabs. Link these with the layout described above.
There is a tutorial here showing you how you can create a tab host.