@SuppressWarnings("deprecation")
public class MainActivity extends TabActivity {
public static TabHost tabHost;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.tab_main);
// call addtab() how many times you need and pass tag and image resource id
}
private void addTab(String tag, int drawableId) {
tabHost = getTabHost();
TabHost.TabSpec spec = tabHost.newTabSpec(tag);
// tab_indicator layout contains only imageview. this is for fix image size, position
View tabIndicator = LayoutInflater.from(this).inflate(
R.layout.tab_indicator, getTabWidget(), false);
ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon);
icon.setImageResource(drawableId);
spec.setIndicator(tabIndicator);
tabHost.addTab(spec);
}
}