Coe*_*nni 2 android android-tabhost
我有一个tabhost创建
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);
Run Code Online (Sandbox Code Playgroud)
我想以编程方式更改tabhost的标签:"Regionlar"到"newMenuTabbar".我找不到任何例子.谢谢你的关注.
编辑:我想从"Mənzərələr"=>"secondTabitem"改变第二个tabitem的标签
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);
// 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);
Run Code Online (Sandbox Code Playgroud)
试试这个:
final TextView label = (TextView) tabHost.getTabWidget().findViewById(android.R.id.title);
label .setText(YOUR NEW LABEL);
Run Code Online (Sandbox Code Playgroud)
希望它会有所帮助.
| 归档时间: |
|
| 查看次数: |
5402 次 |
| 最近记录: |