Cannot be allowed or is not a field (exercises for notepad from android dev site)

I am doing notebook exercises on the Android developer website, currently working on exercises (here here ).

I went to the end of the tutorial, and found that I had a few mistakes in the two main Java files on the relationship the R file, such as setContentView(R.layout.notes_list);andmenu.add(0, INSERT_ID,0, R.string.menu_insert);

I tried to clear and rename to R.javano avail.

They are also found in the solution for the exercise, so I think that these are deliberate errors or something with my eclipse, but I can not fix them, any help would be very grateful!

+3
source share
5 answers

Do you have layout notes_list.xml in your layout folder? Do you have a line called menu_insert in your strings.xml file? This can be a problem, because I think that they do not give EVERYTHING in the textbook ... They 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 the strings.xml file in the value folders:

<string name="menu_insert">Add Note</string>
+7
source

I think you might have to be careful about how you use the ctrl-shift-O command (to automatically insert the import statements at the top of the file). Maybe you get "import android.R;" expression as a "bonus". I commented on "import android.R"; and everything was in order.

+5
source

, , Eclipse android.R, ctrl + shift + o . - :

import com.android.demo.notepad2.R;
+3

You should verify that you have added id to your LinearLayout in any XML layout file. If so, then you should look for something syntactically incorrect, which will prevent the rebuilding of the R file.

Sort of:

android:id="@+id/linearLayout"
0
source

In the hardcoding line do not use space in files .xml. ie @string/a b cwrong try@string/a_b_c

0
source

Source: https://habr.com/ru/post/1756233/


All Articles