Stefan Stefan - 2 months ago 11
Android Question

ERROR: " Cannot resolve symbol '@string/edit_message' " Android Studio

I'm trying to follow the android tutorial on: http://developer.android.com/training/basics/firstapp/building-ui.html
But when I reach the part where you have to add a button my Android Studio keeps returning this errors:

Cannot resolve symbol '@string/edit_message'
Cannot resolve symbol '@string/button_send'


XML Code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<EditText android:id="@+id/edit_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send" />
</LinearLayout>


What am I doing wrong here? I can't find the right solution on other stackoverflow questions and I'm pretty sure i used the right code on the android tutorial from google.

Answer

You must define those 2 strings in strings.xml

     <?xml version="1.0" encoding="utf-8"?>
    <resources>
      ...
        <string name="edit_message">something text /string>
        <string name="button_send">something text</string>
      ...
    </resources>
Comments