Android 安卓TabHost问题

Android 安卓TabHost问题,android,android-tabhost,Android,Android Tabhost,我在应用程序中使用android选项卡。我有一个主类,我在那里导入我的标签。有4个选项卡,因此每个选项卡有1个java类。但在每个标签中,我还涉及到其他意图。当我从一个选项卡移动到其他意图时,选项卡视图将消失。我希望我的选项卡保留在所有类和所有视图中。我该怎么办呢。这是我的主选项卡类代码 意图1; 意图2; 意图3; 意图4 intent1 = new Intent().setClass(this, x.class); spec = tabHost

我在应用程序中使用android选项卡。我有一个主类,我在那里导入我的标签。有4个选项卡,因此每个选项卡有1个java类。但在每个标签中,我还涉及到其他意图。当我从一个选项卡移动到其他意图时,选项卡视图将消失。我希望我的选项卡保留在所有类和所有视图中。我该怎么办呢。这是我的主选项卡类代码

意图1; 意图2; 意图3; 意图4

    intent1 = new Intent().setClass(this, x.class);  

    spec = tabHost
            .newTabSpec("x")
            .setIndicator("x",


    tabHost.addTab(spec);

    intent2 = new Intent().setClass(this, y.class);
    spec = tabHost
            .newTabSpec("y")
            .setIndicator("y",


    tabHost.addTab(spec);

    intent3 = new Intent().setClass(this,z.class);
    spec = tabHost
            .newTabSpec("z")
            .setIndicator("z",


    tabHost.addTab(spec);

    intent4 = new Intent().setClass(this, a.class);
    spec = tabHost
            .newTabSpec("a")
            .setIndicator("a",


    tabHost.addTab(spec);

希望此代码可以帮助您……

xml文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:admobsdk="http://schemas.android.com/apk/res/com.admob.android.example"   
    android:orientation="vertical"      
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >



<LinearLayout 
    android:id="@+id/llTab"
    android:orientation="vertical" 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:visibility="visible"
    android:layout_weight="2">

    <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:focusable="false"
        android:focusableInTouchMode="false">

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"                 
            android:background="@android:color/darker_gray"             
            android:nextFocusUp="@android:id/tabcontent"
            android:layout_gravity="bottom"
            android:focusable="false"
            android:focusableInTouchMode="false"
            />

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:paddingBottom="65dp"
            android:focusable="false"
            android:focusableInTouchMode="false"/>

    </TabHost>

</LinearLayout>
public class ActivityGroup extends TabActivity {
/** Called when the activity is first created. */

    private static final String TAG_TYERS = "Tab1";
    private static final String TAG_BABES = "Tab2";
    private static final String TAG_TEAMS = "Tab3";
    private static final String TAG_EVENTS = "Tab4";
    TabHost tabHost; 

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    tabHost = getTabHost();

    tabHost.addTab(tabHost.newTabSpec("Tab1")
        .setIndicator(TAG_TYERS)
        .setContent(new Intent().setClass(this, Tab1.class)));

    tabHost.addTab(tabHost.newTabSpec("Tab2")
        .setIndicator(TAG_BABES)
        .setContent(new Intent().setClass(this, Tab2.class)));

    tabHost.addTab(tabHost.newTabSpec("Tab3")
        .setIndicator(TAG_EVENTS)
        .setContent(new Intent().setClass(this, Tab3.class)));

    tabHost.addTab(tabHost.newTabSpec("Tab4")
        .setIndicator(TAG_EVENTS)
        .setContent(new Intent().setClass(this, Tab4.class)));

    tabHost.setCurrentTab(0);
}