其他分享
首页 > 其他分享> > 无法解析或不是一个字段(Android开发网站的记事本练习)

无法解析或不是一个字段(Android开发网站的记事本练习)

作者:互联网

我正在浏览android dev网站上的记事本练习,正在进行练习(找到here).

我来到教程的最后,发现我在主要的两个关于R文件关系的java文件中有几个错误,例如setContentView(R.layout.notes_list);和menu.add(0,INSERT_ID,0,R.string.menu_insert);

我试过清洗和重新生成R.java无济于事.

这些也出现在练习的解决方案中,所以我认为它们是故意的错误,或者是我的日食,但我似乎无法修复它们,任何帮助都会非常感谢!

解决方法:

布局文件夹中是否有布局notes_list.xml?
在strings.xml中是否有一个名为menu_insert的字符串?
这可能是问题,因为我认为他们没有在教程中给出一切……
他们确实在解决方案中有它们:

<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content">
<ListView android:id="@+id/android:list" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
<TextView android:id="@+id/android:empty" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/no_notes"/>
</LinearLayout>

在values文件夹的strings.xml中:

<string name="menu_insert">Add Note</string>

标签:android,eclipse,eclipse-plugin,notepad-2
来源: https://codeday.me/bug/20190713/1452116.html