|findViewById, R.id member cannot be resolved [message #1245059]
||Thu, 13 February 2014 08:31
| b lench
Registered: February 2014
First post here - hope this is the appropriate forum for the following question:
I'm using the Java ADT and trying to add a button to a working example project.
The following line produces a "cannot be resolved" error because "toggleButton" is missing from R.id.
Button toggleButton = (Button) findViewById(R.id.toggleButton);
(This seems to be declaring a new variable using a reference to itself.)
The editor offers to "create field 'toggleButton' in type id", but then warns that I'm modifying a "derived file", "R.Java".
How does one declare a variable this way?
FOLLOW UP (for future newbie):
The problem went-away after defining the button in the \res\layout\main.xml (see text below).
Apparently R.java is derived from the XML resource, not from variable declarations in the "source" directory.
android:text="Toggle Silent Mode"
[Updated on: Sun, 16 February 2014 18:50]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.03693 seconds