简体   繁体   中英

“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

  @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


todo_edit is in my layout folder.

it does not start with a capital letter

i have not imported 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

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

  1. check what recent change you did with xml

  2. You can remove and re-add the recent added/changed xml file

At the top of your screen, assuming you're using Eclipse, hit Project -> Clean...

Select the appropriate project if it prompts you, then hit 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!

Check that your todo_edit.xml (and all other XML files) doesn't have errors. When there's an error in one of the resource files, the SDK can't generate the R file.

Also, try cleaning the project and/or hitting Ctrl+B to build it (it may so happen you have autobuild turned off).

Also, try Ctrl+Shift+O to sort out your imports - it should ask you which R you want to import.

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.

All else having failed, try restarting Eclipse - it's a pretty complex environment, so it's ok for it to sometimes go nuts.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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