Java Android ListActivity致命异常

Java Android ListActivity致命异常,java,android,listview,exception,listactivity,Java,Android,Listview,Exception,Listactivity,每当我尝试启动此活动时,都会出现此错误: 01-31 02:19:19.558: E/AndroidRuntime(1318): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.prva/com.example.prva.ListView}: java.lang.RuntimeException: Your content must have a ListView whose id at

每当我尝试启动此活动时,都会出现此错误:

01-31 02:19:19.558: E/AndroidRuntime(1318): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.prva/com.example.prva.ListView}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
列表活动:

package com.example.prva;

import android.app.ListActivity;
import android.database.Cursor;
import android.os.Bundle;
import android.support.v4.widget.SimpleCursorAdapter;


public class ListView extends ListActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.listview);
        fillData();
        }

    private void fillData() {
        // Get all of the notes from the database and create the item list
        Cursor c = DatabaseManager.getAllData();
        startManagingCursor(c);

        String[] from = new String[] { DatabaseManager.TABLE_COLUMN_ONE };
        int[] to = new int[] { R.id.text1 };

        // Now create an array adapter and set it to display using our row
        SimpleCursorAdapter notes =
            new SimpleCursorAdapter(this, R.layout.notes_row, c, from, to);
        setListAdapter(notes);
    }
    }
我的listview 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" >

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

</LinearLayout>


我不明白这一点,因为我有一个listview,id是list?

您必须使用默认的
android.R.id.list
,它位于
@android:id
名称下
@+id
使用名称
列表创建您自己的id

因此,不是:

android:id="@+id/list"
使用以下命令:

android:id="@android:id/list"

将您的ListView id更改为
@android:id/list
,这将解决您的问题。.列表活动的ListView应具有
@android:id/list
。我希望这将对您有所帮助