0

在我之前的 xml 代码中,我的应用程序运行正常:

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

    <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="82dp" >

    <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_toLeftOf="@+id/button1"
        android:ems="10" >

        <requestFocus />
    </EditText>

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:text="Send" />

          </RelativeLayout>

        <ListView
     android:id="@android:id/list"
     android:layout_width="match_parent"
     android:layout_height="380dp" />


     </LinearLayout>

现在,当我更改我的 xml 时,现在当我作为父级进行相对布局或框架布局时,我的应用程序给了我错误“不幸的是它已停止”,我的新 xml 是:

  <?xml version="1.0" encoding="utf-8"?>
   <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent" >

      <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="86dp"
    android:layout_gravity="bottom" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:text="Send" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_toLeftOf="@+id/button1"
        android:ems="10" />

  </RelativeLayout>

  <ListView
    android:id="@+id/listView1"
    android:layout_width="match_parent"
    android:layout_height="372dp" >
  </ListView>

        </FrameLayout>

日志猫:

08-24 19:08:24.050: E/AndroidRuntime(674): 在 android.app.FragmentManagerImpl.moveToState(FragmentManager.java:809) 08-24 19:08:24.050: E/AndroidRuntime(674): 在 android. app.FragmentManagerImpl.moveToState(FragmentManager.java:998) 08-24 19:08:24.050: E/AndroidRuntime(674): 在 android.app.BackStackRecord.run(BackStackRecord.java:622) 08-24 19:08: 24.050: E/AndroidRuntime(674): 在 android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1330) 08-24 19:08:24.050: E/AndroidRuntime(674): 在 android.app.Activity.performStart(Activity .java:4474) 08-24 19:08:24.050: E/AndroidRuntime(674): 在 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1928) 08-24 19:08:24.050: E/AndroidRuntime(674) ): ... 11 更多

4

2 回答 2

1

更改您的 ListView id,如果您扩展 ListActivity 必须指定关键字 android。

 <ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="372dp" >
</ListView>
于 2013-08-24T08:35:12.777 回答
0

抱歉,Ameer Humza,但我在执行你的两个 xml 时没有收到这样的错误。

我认为您应该先尝试清理您的项目:Project > Clean。

或者

重新启动 Eclipse。

你的eclipse是什么版本的?

于 2013-08-24T06:18:51.703 回答