0
我創建了一個主機選項卡,我只會在選項卡上放置圖像。 我發現這個方法:在tabHost上放置一張圖片
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));
但程序走崩潰...
請分享任何圖片。你想要展示什麼? –
圖像是「book.png」,包含在res中,如目前所見伴隨着單詞「tab 1」 – Antilope
你是否只想要顯示圖像 –