Trying to create 2 tabs for TabHost widget. Tabs are created, but they are without names: Untitled


Code

package com.samples.tabhost; import android.app.Activity; import android.os.Bundle; import android.widget.TabHost; public class TabHostActivity extends Activity { @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); TabHost tabs=(TabHost)findViewById(R.id.tabhost); tabs.setup(); TabHost.TabSpec spec=tabs.newTabSpec("tag1"); spec.setContent(R.id.tabPage1); spec.setIndicator("Document 1"); // Указал название 1 вкладки tabs.addTab(spec); spec=tabs.newTabSpec("tag2"); spec.setContent(R.id.tabPage2); spec.setIndicator("Document 2"); // Указал название 2 вкладки tabs.addTab(spec); tabs.setCurrentTab(0); } } 

Markup file:

 <?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingTop="62px"> <EditText android:id="@+id/tabPage1" android:layout_width="fill_parent" android:layout_height="fill_parent" /> <EditText android:id="@+id/tabPage2" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </FrameLayout> </TabHost> 

    1 answer 1

    Your code is error free. I took the Skeleton App from the examples and replaced the sources of the example with yours. Total:

    alt text

    As you can see the names of the tabs are displayed. What else comes to mind?

    1. Unsupported fonts,
    2. Failed resolution
    3. Unsuccessful colors.
    • In the avd settings, the display type is WVGA800. How to find out if fonts are supported? OS Kubuntu 10.10 - gabin
    • First of all, try repeating my steps for avd on android 2.2, WQVGA 400, the rest is default. Skeleton App from Android SDK. - stanislav
    • With the resolution of WQVGA 400 is displayed correctly, thanks. Apparently the bug in the emulator ... Is it possible to make the name of the tab higher, otherwise it, in my opinion, is too pressed to the bottom? - gabin