this.tabHost = getTabHost();
// Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
// Create an Intent to launch the first Activity for the tab (to be reused)
intent = new Intent().setClass(this, FirstGroup.class);
// Initialize a TabSpec for the first tab and add it to the TabHost
spec1 = tabHost.newTabSpec("FirstGroup").setIndicator("Regionlar",
getResources().getDrawable(R.drawable.region2)) // Replace null with R.drawable.your_icon to set tab icon
.setContent(intent);
tabHost.addTab(spec1);
创建tabhost我想以编程方式更改tabhost的标签:“Regionlar”到“newMenuTabbar”。我找不到任何例子。感谢您的关注。
编辑: 我想从 “Mənzərələr”=> “secondTabitem”
意图=新意图()更改第二的TabItem的标签setClass(这一点,FirstGroup.class)。
// Initialize a TabSpec for the first tab and add it to the TabHost
spec1 = tabHost.newTabSpec("FirstGroup").setIndicator("Regionlar",
getResources().getDrawable(R.drawable.region2)) // Replace null with R.drawable.your_icon to set tab icon
.setContent(intent);
tabHost.addTab(spec1);
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, SecondActivityGroup.class);
spec2 = tabHost.newTabSpec("SecondActivityGroup").setIndicator("Mənzərələr",
getResources().getDrawable(R.drawable.img_gallery_icon)) // Replace null with R.drawable.your_icon to set tab icon
.setContent(intent);
tabHost.addTab(spec2);
如何更改第二个tabitem的标签?我编辑了这个问题。 – Coenni 2012-04-26 08:45:35
我已经解决了: final TextView label =(TextView)tabHost.getTabWidget()。getChildAt(1).findViewById(android.R.id.title); \t label .setText(“newTabmenu”); 您可以使用getchildat(i)方法更改tabitem的每个标签。 – Coenni 2012-04-26 08:51:11
是的,你可以得到每个标签的索引: final int k = tabHost.getCurrentTab(); – 2012-04-26 08:52:21