Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » findViewById, R.id member cannot be resolved
findViewById, R.id member cannot be resolved [message #1245059] Thu, 13 February 2014 03:31
Eclipse UserFriend
Hi,
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?

Thanks/Cheers.

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.
" <Button
android:id="@+id/toggleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Toggle Silent Mode"
/>
"

[Updated on: Sun, 16 February 2014 13:50] by Moderator

Previous Topic:Remote Debugging Issue
Next Topic:ap file turn to gibberish
Goto Forum:
  


Current Time: Thu Apr 24 21:10:27 EDT 2025

Powered by FUDForum. Page generated in 0.02899 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top