我使用 android.support.v4.app.FragmentTabHost 编写了 Tab Navigation 的应用程序。我想将图像背景添加到我的选项卡。代码在这里:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tab);
instance = this;
history = new HashMap<String, Stack<Fragment>>();
tabhost = (FragmentTabHost)findViewById(android.R.id.tabhost);
tabhost = (FragmentTabHost)findViewById(android.R.id.tabhost);
tabhost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
TabSpec tab1 = tabhost.newTabSpec("0").setIndicator("Home");
TabSpec tab2 = tabhost.newTabSpec("1").setIndicator("Sign Up");
TabSpec tab3 = tabhost.newTabSpec("2").setIndicator("Tab3");
System.out.print("second out");
tabhost.addTab(tab1, myFragment.class, null);
tabhost.addTab(tab2, myFragment2.class, null);
tabhost.addTab(tab3, myFragment3.class, null);