I am new to Android (but not to Java), I follow sample exercice NotepadV1 but I get a strange error while executing on virtual device (Hello World worked fine on this same vd):
I get a "Resource not found" exception when running the program. The used ID is correct (Eclipse show it to me as an autocompletion proposal, and it's well defined in R.java). If I use directly the string instead of the resource ID, all things are good.
Here is my string.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string
name="app_name">Notepad v1</string>
<string
name="no_notes">No Notes Yet</string>
<string
name="menu_insert">Add Item</string>
</resources>
And here is the function where the exception is thrown:
@Override
public boolean onCreateOptionsMenu( Menu menu )
{
boolean result = super.onCreateOptionsMenu( menu );
// menu.add( 0, INSERT_ID, 0, R.string.menu_insert ); // exception !
menu.add( 0, INSERT_ID, 0, "Add Item" ); // ok like this
return result;
}
The commented out line is the one which throws exception. As you see, when giving directly the string instead of resource ID, it pass. I've tried to load this resource elsewhere in the same program, and the exception is thrown everywhere. Other resources are used on other places in the program, without problem.
Anybody have an idea ? Did I missed something ?
Thanks a lot for your ideas