Code example for TabHost

Methods: addTabnewTabSpecsetCurrentTab

0
 
		super.onCreate(savedInstanceState);
 
		tabHost = getTabHost();
 
		tabHost.addTab(tabHost
				.newTabSpec(eu.fbk.dycapo.activities.Settings.TAB_TAGS[0])
				.setContent(new Intent(this, Me.class))
				.setIndicator(
						eu.fbk.dycapo.activities.Settings.TAB_TAGS[0],
						getResources().getDrawable(
								android.R.drawable.ic_menu_info_details)));
		tabHost.addTab(tabHost
				.newTabSpec(eu.fbk.dycapo.activities.Settings.TAB_TAGS[1])
				.setContent(new Intent(this, Prefs.class))
				.setIndicator(
						eu.fbk.dycapo.activities.Settings.TAB_TAGS[1],
						getResources().getDrawable(
								android.R.drawable.ic_menu_preferences)));
		tabHost.addTab(tabHost
				.newTabSpec(eu.fbk.dycapo.activities.Settings.TAB_TAGS[2])
				.setContent(new Intent(this, Car.class))
				.setIndicator(
						eu.fbk.dycapo.activities.Settings.TAB_TAGS[2],
						getResources().getDrawable(
								android.R.drawable.ic_menu_compass)));
		tabHost.addTab(tabHost
				.newTabSpec(eu.fbk.dycapo.activities.Settings.TAB_TAGS[3])
				.setContent(new Intent(this, Social.class))
				.setIndicator(
						eu.fbk.dycapo.activities.Settings.TAB_TAGS[3],
						getResources().getDrawable(
								android.R.drawable.ic_menu_send)));
 
		if (this.getIntent().hasExtra(TAB_FOCUS))
			tabHost.setCurrentTab(this.getIntent().getIntExtra(TAB_FOCUS, ME));
	} 
 
}