0

I created a host tab and I would only put an image on a tab. I found this method:

    tabHost.addTab(tabHost.newTabSpec("Tab 1").setContent(R.id.tab1)
            .setIndicator("Tab 1",getResources().getDrawable(R.drawable.book)));

that provides text and image, but no good. How should I do?

EDIT

I tried putting in 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>

I put in the activity the following statement:

    tabHost.addTab(tabHost.newTabSpec("Tab 1").setContent(R.id.tab1));

but the program go crash...

Antilope
  • 443
  • 2
  • 6
  • 17

1 Answers1

1

I have looked around for similar question relating to your problem, I think if you take a look at the answers provided in the following question, you may find some answers to help you:

How to change the Tabs Images in the TabHost

Hope this helps.

Community
  • 1
  • 1
kibria3
  • 289
  • 1
  • 4
  • 21