Back to project page EnterpriseShow.
The source code is released under:
This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a co...
If you think the Android project EnterpriseShow listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.ruixinyuan.producttrainingfinal.utils; /*from w w w . j a va 2s . com*/ import android.app.TabActivity; import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.widget.LinearLayout; import android.widget.TabHost; import android.widget.TabHost.TabSpec; import android.widget.TabWidget; import android.widget.TextView; import com.ruixinyuan.producttrainingfinal.R; /* *@user vicentliu *@time 2013-6-8????10:24:19 *@package com.ruixinyuan.producttrainingfinal.utils *????????????????????????tabHost */ public abstract class TabHostActivity extends TabActivity { private TabHost mTabHost; private TabWidget mTabWidget; private LayoutInflater mLayoutInflater; @Override protected void onCreate(Bundle savedInstanceState) { // TODO super.onCreate(savedInstanceState); setTheme(R.style.Theme_Tabhost); setContentView(R.layout.tab_host); mLayoutInflater = getLayoutInflater(); mTabHost = getTabHost(); mTabWidget = getTabWidget(); prepare(); initTop(); initTabSpec(); } private void initTop() { View child = getTop(); LinearLayout l = (LinearLayout)findViewById(R.id.tab_top); l.addView(child); } private void initTabSpec() { int count = getTabItemCount(); for (int i = 0; i < count; i++) { View tabItem = mLayoutInflater.inflate(R.layout.tab_item, null); TextView tabItemTv = (TextView)tabItem.findViewById(R.id.tab_item_textview); setTabItemTextView(tabItemTv, i); String tabItemId = getTabItemId(i); TabSpec tabSpec = mTabHost.newTabSpec(tabItemId); tabSpec.setIndicator(tabItem); tabSpec.setContent(getTabItemIntent(i)); mTabHost.addTab(tabSpec); } } //????????????? protected void prepare() { //todo:override it } //??????? protected View getTop() { return null; } protected int getTabCount() { return mTabHost.getTabWidget().getTabCount(); } //??tabItem??????? abstract protected void setTabItemTextView(TextView textView,int position); abstract protected String getTabItemId(int position); abstract protected Intent getTabItemIntent(int position); abstract protected int getTabItemCount(); protected void setCurrentTab(int index) { mTabHost.setCurrentTab(index); } protected void focusCurrentTab(int index) { mTabWidget.focusCurrentTab(index); } }