Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在ListView中加载布局时出现问题_Android - Fatal编程技术网

Android 在ListView中加载布局时出现问题

Android 在ListView中加载布局时出现问题,android,Android,所以,这根本不起作用!当我尝试使用ListView在我的应用程序中加载布局时,应用程序失败并关闭 以下是main.xml的布局: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="

所以,这根本不起作用!当我尝试使用ListView在我的应用程序中加载布局时,应用程序失败并关闭

以下是main.xml的布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent">
    <ListView android:id="@+id/listView" android:scrollbars="none"
              android:layout_alignParentTop="true" android:layout_height="wrap_content"              android:layout_gravity="top" android:layout_margin="0dp" android:layout_width="fill_parent" android:layout_weight="7"></ListView>
    <LinearLayout android:layout_alignParentBottom="true" android:orientation="horizontal"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content">
         <Button android:id="@+id/start" android:text="Start" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"></Button>
    </LinearLayout>
</RelativeLayout>
我一直在寻找解决方案,但我只找到了布局真正加载的情况。这里的情况更糟。
应用程序在setContentView中失败!怎么了?

您正在扩展ListActivity;因此,您的ListView必须具有扩展ListActivity的id
@android:id/list

;因此,您的ListView必须具有id
@android:id/list

您可以发布LogCat或stacktrace吗?您可以发布LogCat或stacktrace吗?
public class main extends ListActivity {
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    ...