I am trying to create an android application that have a tab view in Home_Tab Activity.
it has 4 tabs. i want to make some modification to the view, that is, when i click on the first tab it shows 4 child tab under that tab. how to create it ,
my code is given below
public class Home_tab extends TabActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home_main);
Resources ressources = getResources();
TabHost tabHost = getTabHost();
// Android tab
Intent intentAndroid = new Intent().setClass(this, CoalActivity.class);
TabSpec tabSpecAndroid = tabHost
.newTabSpec("Android")
.setIndicator("", ressources.getDrawable(R.drawable.tab_dis))
.setContent(intentAndroid);
// Apple tab
Intent intentApple = new Intent().setClass(this, EnergyActivity.class);
TabSpec tabSpecApple = tabHost
.newTabSpec("Apple")
.setIndicator("", ressources.getDrawable(R.drawable.tab_foc))
.setContent(intentApple);
// Windows tab
Intent intentWindows = new Intent().setClass(this, PowerActivity.class);
TabSpec tabSpecWindows = tabHost
.newTabSpec("Windows")
.setIndicator("", ressources.getDrawable(R.drawable.tab_nor))
.setContent(intentWindows);
// Blackberry tab
Intent intentBerry = new Intent().setClass(this, TopNewsActivity.class);
TabSpec tabSpecBerry = tabHost
.newTabSpec("Berry")
.setIndicator("", ressources.getDrawable(R.drawable.tab_sel))
.setContent(intentBerry);
// add all tabs
tabHost.addTab(tabSpecAndroid);
tabHost.addTab(tabSpecApple);
tabHost.addTab(tabSpecWindows);
tabHost.addTab(tabSpecBerry);
//set Windows tab as default (zero based)
tabHost.setCurrentTab(0);
}
}
You need to create class (CoalActivity) extends tabactivity again. and create new tab spec
simple ………….