Yesterday I did my first bit of Android development ever. I created a very simple program that simply updated some text on screen.
I had a problem though. On my Activity, I had the following piece of code:
And the following bit ox XML in my layout (inside a LinearLayout):
Eclipse insisted that R.id
was illegal. Specifically, the error was id
cannot be resolved or is not a field
, even though the button did exist in the
view.
The problem was that I had not yet defined the string "button" in my
strings.xml
file:
1<string name="button">Click me!</string>
Not sure of the exact internals, but I guess that Eclipse was trying to compile the layout, and it failed because the string was missing. In turn, this showed an error in the activity, because it was using a broken layout.