0

我创建了一个TabHost包含 4 个选项卡规范的主要活动。我已经为 Tab 主机设置了背景(可绘制、png 图像),并使标签规范中的所有活动都是透明的。

例如:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" >

    <!-- Dummy item to prevent EditText from receiving focus -->

    <LinearLayout
        android:focusable="true" android:focusableInTouchMode="true"
        android:layout_width="0px" android:layout_height="0px"/>

    <EditText android:id="@+id/etContactSearch" 
        android:layout_height="60dip" 
        android:layout_width="fill_parent" 
        android:drawableRight="@drawable/search_contact" >

    </EditText>

    <ListView android:id="@+id/lvContacts" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"  
        android:layout_margin="1dp"  
        android:cacheColorHint="#00000000" 
        android:listSelector="@drawable/relative_layout_clickable">

    </ListView>
</LinearLayout>

并且其中一个选项卡规范具有一些线性布局和列表活动:

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@android:id/tabhost"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:background="@drawable/bck_list">

   <LinearLayout
       android:orientation="vertical"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       android:padding="0dp">

       <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:padding="0dp" />

    </LinearLayout>
</TabHost>

当我从 Eclipse 启动应用程序时,它第一次运行时,背景 ( @drawable/bck_list) 完美显示。但是如果我关闭应用程序并再次运行它,背景就会丢失(而是显示黑色)。

这里有什么问题?

4

1 回答 1

0
mTabHost.addTab(mTabHost
                .newTabSpec("tab_1")
                .setIndicator(g(R.string.TList))
                .setIndicator(g(R.string.TList),
                        getResources().getDrawable(R.drawable.lis))
                .setContent(new Intent().setClass(this, GList.class)));
于 2012-05-10T14:21:06.603 回答