标签活动折旧后如何在Android中使用标签?通过使用福尔摩斯和碎片,我能够进行制表,但我想将制表符图像设置为整个而不是制表符图标...我不需要带黑色bg的图像,而我希望我的图像在整个制表符上。这是我的代码
private FragmentTabHost mTabHost;
mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
// mTabHost.setup(this, getSupportFragmentManager(), R.id.tabFrameLayout);
mTabHost.setup(this, getSupportFragmentManager(), android.R.id.tabcontent);
mTabHost.addTab(
mTabHost.newTabSpec("tab1").setIndicator("",
getResources().getDrawable(R.drawable.tab8)),
FragmentTab.class, null);
mTabHost.addTab(
mTabHost.newTabSpec("tab2").setIndicator("Tab 2",
getResources().getDrawable(R.drawable.tab9)),
FragmentTab.class, null);
mTabHost.addTab(
mTabHost.newTabSpec("tab3").setIndicator("Tab 3",
getResources().getDrawable(android.R.drawable.star_on)),
FragmentTab.class, null);
mTabHost.addTab(
mTabHost.newTabSpec("tab4").setIndicator("Tab 4",
getResources().getDrawable(android.R.drawable.star_on)),
FragmentTab.class, null);
Help Required :)
我通过使用tabhost来做到这一点,您可以在没有tabactivity的情况下使用tabhost,其代码如下。
final TabHost tabHost=(TabHost)findViewById(R.id.tabhost);
tabHost.setup();
final TabSpec spec1 = tabHost.newTabSpec("Tab1");
View view = LayoutInflater.from(this).inflate(R.layout.tabbar8, tabHost.getTabWidget(), false);
spec1.setIndicator(view);
spec1.setContent(R.id.tab1);
其中tabbar8是要在第一个标签上设置的布局
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句