Cannot be resolved or is not a field (Notepad exercises from android dev website)

 picture · Jul 23, 2010 · Viewed 23.8k times · Source

I'm running through the notepad exercises on the android dev website, currently working on exercise (found here).

I came to the end of the tutorial and found that I had several errors in the main two java files regarding R file relations, such as setContentView(R.layout.notes_list); and menu.add(0, INSERT_ID,0, R.string.menu_insert);

I've tried cleaning and re-genning R.java to no avail.

These also occur in the solution for the exercise so I think they are deliberate mistakes, or something with my eclipse, but I can't seem to fix them, any help would be great thanks!

Answer

Sephy picture Sephy · Jul 23, 2010

Do you have the layout notes_list.xml in your layout folder? Do you have a string by the name of menu_insert in your strings.xml? This might be the issue, because I think they don't give EVERYTHING in the tutorial... They do have them in the solution :

<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content">
<ListView android:id="@+id/android:list" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
<TextView android:id="@+id/android:empty" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/no_notes"/>
</LinearLayout>

in strings.xml in values folder :

<string name="menu_insert">Add Note</string>