2013-01-10 71 views
0

尝试设置列表视图和我的数据库查询的结果。XML列表视图问题

无论如何,我从我的列表视图中得到一个奇怪的XML refrence id错误。任何人都可以在这里看到问题?我猜它的'@id'引用导致问题?

我的继承人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/contentList" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 
</ListView> 

</LinearLayout> 

我的java类:

的错误是在 'R.id.conactList'。

ListView listContent = (ListView)findViewById(R.id.contentList); 
+0

你丢失大量的相关信息(堆栈跟踪,当你调用findViewById,该类从发出的呼吁,为什么你使用'id.contactList',而不是'id.contentList'等)但我会猜测你没有设置你的活动的内容视图。 – AedonEtLIRA

回答

0

这对我来说很好。您可以将></ListView>更改为/>以稍微清理xml。尝试清理您的项目以确保您的R文件得到更新。有日志可以发布吗?究竟是什么错误?

+0

嗨,詹姆斯。我已经清理了很多次。实际上,错误在'contentList'引用上,并且错误被描述为'布局不能被解析,或者不是字段'。 – user1352057

+0

确保你从包中导入了'R.java'文件,而不是像'android'这样的其他包。你可以调查你的R文件并检查'contactList'是否定义在那里? –