parisminton
parisminton

Reputation: 401

How can I get Android to resolve XML resources?

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"

Two lines calling to the same XML file; one gives an error.

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

I don't see any glaring errors in my XML.

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.

Upvotes: 2

Views: 418

Answers (2)

ptc
ptc

Reputation: 56

try removing the R import lines altogether

Upvotes: 2

dave.c
dave.c

Reputation: 10908

Instead of importing android.R try importing com.android.demo.notepad3.R

Upvotes: 1

Related Questions