这是我设置片段标签的活动:
private FragmentTabHost mTabHost;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bottom_tabs);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
Bundle b = new Bundle();
b.putString("key", "Simple");
mTabHost.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"),this.getResources().getDrawable(R.drawable.iconxml)
Fragment1.class, b);
iconxml.xml文件
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/ic_launcher" />
<item android:drawable="@drawable/icontab" />
我的应用程序崩溃了.. plz help
![例外] [logcat outout]
答案 0 :(得分:1)
尝试改变这一点:
mTabHost.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple",getResources().getDrawable(R.drawable.iconxml)
Fragment1.class, b);
答案 1 :(得分:0)
将其替换为
mTabHost.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"),this.getResources().getDrawable(R.drawable.iconxml) Fragment1.class, b);
此
mTabHost.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple",this.getResources().getDrawable(R.drawable.iconxml)) Fragment1.class, b);
答案 2 :(得分:0)