android - 神秘!我的一个 .xml 布局资源未被检测到!这是怎么回事?

标签 android listview layout resources

更新:已解决,我是白痴,谢谢大家!

Okay little bit weird.. I just created a layout file for list items, I can see it there now, in my res/layout folder. It's called itemListBudget.xml. Inside i've declare two id's, catItem and budgetAmount as you can see here: http://pastebin.com/ZV0wr9L0 (it'll only take a second to look at)

So now i'm just trying to bind data from my sqlite table to my list! Here's my method:

//
private static int[] TO = { R.id.catItem, R.id.budgetAmount, };
private void showBudgetOutcome(Cursor cursor) {
    //Set up data binding 
    SimpleCursorAdapter adapter = new SimpleCursorAdapter(
            this, R.layout.itemListBudget, cursor, FROM, TO,);
    setListAdapter(adapter);

}

Now i'm being told that R.id.catItem cannot be resolved. R.id.budgetAmount cannot be resolved and of course R.layout.itemListBudget cannot be resolved. Why on earth could this be?

I also have an error message saying my setListAdapter(adapter) is undefined, but i think that's caused by the problem above right?

最佳答案

如果在 Eclipse 中尝试对项目进行清理并强制其重建 R.java

您的布局文件名中不能有大写字母!!! 它的 [a-z0-9_.]

关于android - 神秘!我的一个 .xml 布局资源未被检测到!这是怎么回事?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4319263/

相关文章:

c# - mvvm 绑定(bind) selecteditem 以更新 ListView

swift - 约束不断变化但布局没有更新?

java - 运行应用程序时布局不显示

java - 布局中的 WebView ,顶部有 4 个 TextView

java - 使用不同的 Android 开关样式?

android - 将 ForeignCollection 转换为 ArrayList - ORMLite、Gson 和 Android

android - 使用图层列表创建渐变描边

android - 在 android 滚动 ListView 中动态加载更多项目的最佳方法

android - 所有屏幕尺寸的资源文件夹名称

java - ListView不会显示数组: Android中的元素