有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Android应用程序在setContentView上崩溃

我是安卓开发的新手,代码在setContentView(R.layout.main)崩溃。我不知道为什么。我已经尝试过标准的clean和build并重新启动eclipse

主要代码:

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

}

梅因。xml代码:

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

    <TabHost xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
        安卓:id="@安卓:id/tabhost" 安卓:layout_width="fill_parent"
        安卓:layout_height="fill_parent">
        <LinearLayout 安卓:orientation="vertical"
            安卓:layout_width="fill_parent" 安卓:layout_height="fill_parent">
            <View 安卓:layout_width="fill_parent" 安卓:layout_height="0.5dip"
                安卓:background="#000" />
            <TabWidget 安卓:id="@安卓:id/tabs"
                安卓:layout_width="fill_parent" 安卓:layout_height="wrap_content"
                安卓:layout_marginLeft="0dip" 安卓:layout_marginRight="0dip" />
            <View 安卓:layout_width="fill_parent" 安卓:layout_height="2dip"
                安卓:background="#696969" />
            <View 安卓:layout_width="fill_parent" 安卓:layout_height="2dip"
                安卓:background="#000" />
            <FrameLayout 安卓:id="@安卓:id/tabcontent"
                安卓:layout_width="fill_parent" 安卓:layout_height="fill_parent" />
        </LinearLayout>
    </TabHost>

</LinearLayout>

共 (1) 个答案

  1. # 1 楼答案

    从TabHost中删除xmlns。布局xml文件中应该只有一个XMLN

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