I'm doing Example 3 on the Notepad tutorial on developer.android.com.
It's time to run my code, but I can't even compile, because I have errors on lines that call R.layout.*something*
or R.string.*something*
. Every error is of the type...
"something cannot be resolved or is not a field."
...which signals to me that maybe I named something wrong or forgot to name it in the XML. So I check my XML files and do a little cleanup. Everything seems to be normal. No red Xs.
I go back to the class, where I see what looks odd to me开发者_如何学编程. In two separate lines that call to two separate elements in the same layout file, one yields an error and one doesn't:
mTitleText = (EditText) findViewById(R.id.title); // no error
mBodyText = (EditText) findViewById(R.id.body); // error: "body cannot be resolved or is not a field"
Again, Eclipse isn't showing me any errors on the XML file:
What might I have done wrong that some of the resources are resolving in the code and some aren't? Is this something Eclipse can sort out, similar to Project -> Clean...?
If it makes any difference, I picked Android 2.1 as a build target. And I am importing android.R.
Thanks in advance for any help.
try removing the R import lines altogether
Instead of importing android.R
try importing com.android.demo.notepad3.R
精彩评论