Android中的TabWidget出错

Android中的TabWidget出错,android,Android,我正在关注androiddevelopers网站上的教程。我复制了代码,mTabHost给出了一个错误。我想看看是否有什么东西需要进口,但所有东西都是进口的 代码 package com.tabTestx; import android.app.Activity; import android.app.TabActivity; import android.os.Bundle; public class TabTestXActivity extends TabActivity { publi

我正在关注androiddevelopers网站上的教程。我复制了代码,mTabHost给出了一个错误。我想看看是否有什么东西需要进口,但所有东西都是进口的

代码

package com.tabTestx;

import android.app.Activity;
import android.app.TabActivity;
import android.os.Bundle;

public class TabTestXActivity extends TabActivity {
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mTabHost = getTabHost();

    mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("TAB 1").setContent(R.id.textview1));
    mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("TAB 2").setContent(R.id.textview2));
    mTabHost.addTab(mTabHost.newTabSpec("tab_test3").setIndicator("TAB 3").setContent(R.id.textview3));

    mTabHost.setCurrentTab(0);
}
}

有人请帮帮我

你忘了将
mTabHost
声明为
TabHost

TabHost mTabHost = getTabHost(); //declare as TabHost in your code
^^^^^^^   

您是否有xml格式的android:id/tabhost

      <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="5dp"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="5dp"
                android:layout_marginTop="5dp"
                android:background="@drawable/rounded_border"/>

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" 
                android:background="@android:color/white">


            </FrameLayout>
        </LinearLayout>
    </TabHost>

导入TabHost,如下所示

TabHost mTabHost = getTabHost(); 

有关更多信息,请参阅这些链接,

@Aerrow mTabHost以红色下划线。我还没有运行它,没关系,我让它工作了。只需要TabHost mTabHost=getTabHost();如何将另一个文本视图添加到同一个tab_test1?您不能。您可以在字符串中添加更多文本
(“tab_test1在此添加另一个文本…”)
,但不能添加多个文本您不能添加任何内容来代替文本。是的,我已经有一个复选框。。我还需要一个。不可能?