开发者

How can I get Android to resolve XML resources?

开发者 https://www.devze.com 2023-02-10 05:34 出处:网络
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.

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"

How can I get Android to resolve XML resources?

Again, Eclipse isn't showing me any errors on the XML file:

How can I get Android to resolve XML resources?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消