目前我在Android应用程序中工作,使用TabHost设置五个标签,然后我尝试在标签栏中添加图标,但我不知道,如何设置它?请帮帮我
先谢谢
我在这里尝试过提及你的参考:
//firstTab.setIcon(R.drawable.help);
//firstTab.setIconSelected(R.drawable.help_selected);
TabHost tabHost = getTabHost();
tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("1").setContent(new Intent(this, First.class)));
tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("2").setContent(new Intent(this, Second.class)));
tabHost.addTab(tabHost.newTabSpec("tab3").setIndicator("3").setContent(new Intent(this, Third.class)));
tabHost.addTab(tabHost.newTabSpec("tab4").setIndicator("4").setContent(new Intent(this, Fourth.class)));
tabHost.addTab(tabHost.newTabSpec("tab5").setIndicator("5").setContent(new Intent(this, Fifth.class)));
tabHost.setCurrentTab(2);
答案 0 :(得分:3)
使用也接受Drawable参数的重载setIndicator()方法:
tabHost.addTab(tabHost.newTabSpec("tab5").setIndicator("5", YOUR_DRAWABLE).setContent(new Intent(this, Fifth.class)));
示例:
tabHost.addTab(tabHost.newTabSpec("tab5").setIndicator("5", getResources().getDrawable(android.R.drawable.arrow_down_float)).setContent(new Intent(this, Fifth.class)));