首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >RuntimeException:您的内容必须具有id属性为“”android.R.id.list“”的ListView“”

RuntimeException:您的内容必须具有id属性为“”android.R.id.list“”的ListView“”
EN

Stack Overflow用户
提问于 2010-06-15 03:45:18
回答 7查看 93.3K关注 0票数 87

我得到了一个运行时异常

java.lang.RuntimeException:您的内容必须具有id属性为“”android.R.id.list“”的ListView

我不知道哪里出了问题。

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.newslist);
    mDbHelper.open();
    fillData();
}

private void fillData() {
    Bundle extras = getIntent().getExtras();
    long catID = extras.getLong("cat_id");
    Cursor c = mDbHelper.fetchNews(catID);
    startManagingCursor(c);

    String[] from = new String[] { DBHelper.KEY_TITLE };
    int[] to = new int[] { R.id.newslist_text };

    SimpleCursorAdapter notes = new SimpleCursorAdapter(this, R.layout.text_newslist, c, from, to);
    setListAdapter(notes);
}

newslist.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content">
    <ListView 
         android:id="@+id/catnewslist"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content">
    </ListView>
</LinearLayout>

text_newslist.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <TextView 
        android:text="@+id/newslist_text"
        android:id="@+id/newslist_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">    
    </TextView>
</LinearLayout>
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3040374

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档