For those in the future. Whenever I have this problem it is invariably an XML problem. For me, it is generally always the menu. As far as i can tell it is an eclipse problem because I can delete the whole XML and the R.java will update. I can post the whole XML back in unchanged and the program will compile and run without problem. It is tedious but I can work around it.
attrs not resolved or not a field
Frage
As with many I am writing my first app. I am trying to use the three button toggle from here: http://androidasilearnit.wordpress.com/2011/03/05/custom-toggle-button/
The only problem I have at the moment is I have created the attrs.xml file and it is in the res/values folder. However, when I have created the TriToggleButton.java class I am getting errors on all three states that are declared in attrs.xml
//Get the attributes created in attrs.xml
private static final int[] STATE_ONE_SET =
{
R.attr.state_one
};
private static final int[] STATE_TWO_SET =
{
R.attr.state_two
};
private static final int[] STATE_THREE_SET =
{
R.attr.state_three
};
I have looked in R.java (as that was a suggested fix) and they are not in there. I can see all the other XML info in there but not the attr
Any ideas?
Edit: Here is the attrs.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="CustomButtonState">
<!-- Use one for every state you want to have -->
<attr name="litres" format="boolean" />
<attr name="usgal" format="boolean" />
<attr name="impgal" format="boolean" />
</declare-styleable>
</resources>
Oh and the clean has really broken it. Now all my resources are not being found!! IN MainActivity.java I am now getting "R cannot be resolved to a variable"
Lösung