简体   繁体   English

“无法解决或不是字段” — android — vogella教程

[英]“cannot be resolved or is not a field” — android — vogella tutorial

i just did this tutorial here: http://www.vogella.com/articles/AndroidSQLite/article.html#todo 我只是在这里做过本教程: http : //www.vogella.com/articles/AndroidSQLite/article.html#todo

  @Override
  protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.todo_edit);

in the last line Eclipse underlines the todo_edit and says: todo_edit cannot be resolved or is not a field 在最后一行中, Eclipse在todo_edit下划线并说:todo_edit无法解析或不是字段


todo_edit is in my layout folder. todo_edit在我的布局文件夹中。

it does not start with a capital letter 它不是以大写字母开头

i have not imported android.R 我尚未导入android.R


i dont get where the error might be. 我不知道错误可能在哪里。 ( again: its not even my own code, it was made by professionals ) (再次:它甚至不是我自己的代码,它是由专业人员制作的)

any ideas ? 有任何想法吗 ?

You must check your xml files is there any error 您必须检查您的xml文件是否存在任何错误

If it is not building R.java that means there is some error in any of your xml or manifest file check it deeply it wont build until then 如果不是在构建R.java,则意味着您的任何xml或清单文件中都存在错误,请对其进行深入检查,直到那时为止

  1. check what recent change you did with xml 检查您最近对xml所做的更改

  2. You can remove and re-add the recent added/changed xml file 您可以删除并重新添加最近添加/更改的xml文件

At the top of your screen, assuming you're using Eclipse, hit Project -> Clean... 假设您使用的是Eclipse,请在屏幕顶部,点击Project-> Clean ...

Select the appropriate project if it prompts you, then hit Project -> Build All. 如果提示您选择合适的项目,然后单击Project-> Build All。

If this does not resolve the issue, there is either an error in one of your XML files or it really doesn't exist! 如果这样不能解决问题,则说明您的XML文件中有一个错误,或者实际上不存在该错误!

Check that your todo_edit.xml (and all other XML files) doesn't have errors. 检查您的todo_edit.xml (以及所有其他XML文件)是否没有错误。 When there's an error in one of the resource files, the SDK can't generate the R file. 如果其中一个资源文件有错误,则SDK无法生成R文件。

Also, try cleaning the project and/or hitting Ctrl+B to build it (it may so happen you have autobuild turned off). 另外,尝试清理项目和/或Ctrl+B进行构建(可能是因为您关闭了自动构建功能)。

Also, try Ctrl+Shift+O to sort out your imports - it should ask you which R you want to import. 另外,请尝试Ctrl+Shift+O整理您的导入-它会询问您要导入哪个R

Also, check that none of your resources (incl images) have any kind of improper characters in names. 另外,请检查您的资源(包括图像)中的名称是否包含任何不正确的字符。 Eg the SDK doesn't like it when there are hyphens in the names. 例如,名称中包含连字符时,SDK不喜欢它。

All else having failed, try restarting Eclipse - it's a pretty complex environment, so it's ok for it to sometimes go nuts. 其他所有方法都失败了,请尝试重新启动Eclipse-这是一个非常复杂的环境,因此有时可能会发疯。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM