我创建了一个主机选项卡,我只会将图像放在选项卡上。我找到了这个方法:
tabHost.addTab(tabHost.newTabSpec("Tab 1").setContent(R.id.tab1)
.setIndicator("Tab 1",getResources().getDrawable(R.drawable.book)));
提供文本和图像,但没有好处。我应该怎么做?
编辑
我尝试放入 main.xml:
<LinearLayout
android:id="@+id/tab1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/x2"
android:src="@drawable/book"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
我在活动中添加了以下声明:
tabHost.addTab(tabHost.newTabSpec("Tab 1").setContent(R.id.tab1));
但是程序崩溃了...