最佳答案
您可以像这样为应用程序实现选项卡
在onCreate方法中
TabHost tabHost = getTabHost();
tabHost.setCurrentTabByTag("First");
TabSpec firstTab = tabHost.newTabSpec("First");
firstTab.setIndicator("firstTab",getResources().getDrawable(R.drawable.ic_action_first)); //drawable 1
firstTab.setContent(R.id.first_content); //View
tabHost.addTab(firstTab);
TabSpec secondTab = tabHost.newTabSpec("Second");
secondTab.setIndicator("secondTab",getResources().getDrawable(R.drawable.ic_action_second)); //drawable 2
secondTab.setContent(R.id.second_content); //View
tabHost.addTab(secondTab);
TabSpec thirdTab = tabHost.newTabSpec("Third");
thirdTab.setIndicator("thirdTab",getResources().getDrawable(R.drawable.ic_action_third)); //drawable 3
thirdTab.setContent(R.id.third_content); //View
tabHost.addTab(thirdTab);
tabHost.setCurrentTab(0);
在xml文件中
在getResources()调用你的drawable.getDrawable(R.drawable.drawableid));