Code example for TabHost

Methods: getContextaddTabnewTabSpec

0
		intent = new Intent().setClass(this, SettingActivity.class);
		setupTab(intent, "Setting", R.drawable.tab_img_selector_setting);
	} 
 
	private void setupTab(final Intent intent, final String tag, int imageId) {
		View tabview = createTabView(mTabHost.getContext(), tag, imageId);
	        TabSpec setContent = mTabHost.newTabSpec(tag).setIndicator(tabview).setContent(intent);
		mTabHost.addTab(setContent);
	} 
 
	private static View createTabView(final Context context, final String text, int imageId) {
		View view = LayoutInflater.from(context).inflate(R.layout.tabs_bg, null);
		ImageView img = (ImageView)view.findViewById(R.id.tabsImg);
		img.setImageResource(imageId);
		TextView tv = (TextView) view.findViewById(R.id.tabsText);
		tv.setText(text);
		Typeface font = Typeface.createFromAsset(context.getAssets(), "aescrawl.ttf");
		tv.setTypeface(font);
		return view;
	}