TabHost m = (TabHost)findViewById(R.id.tabhost);
m.setup();
LayoutInflater i=LayoutInflater.from(this);
i.inflate(R.layout.tab1, m.getTabContentView());
i.inflate(R.layout.tab2, m.getTabContentView());//动态载入XML,而不需要Activity
//简单标签
//m.addTab(m.newTabSpec("tab1").setIndicator("标签1").setContent(R.id.LinearLayout01));
//m.addTab(m.newTabSpec("tab2").setIndicator("标签2").setContent(R.id.LinearLayout02));
//带图标的标签
TabSpec tab1 = m.newTabSpec("tab1").setIndicator("主页",
this.getResources().getDrawable(R.drawable.icon_home_nor)).setContent(R.id.LinearLayout01);//设置饮食TabSpec
m.addTab(tab1); //添加到标签中
TabSpec tab2 = m.newTabSpec("tab2").setIndicator("标题",
this.getResources().getDrawable(R.drawable.icon_meassage_nor)).setContent(R.id.LinearLayout02);
m.addTab(tab2); //添加到标签中