Reputation: 41
I am just getting started attempting to learn Eclipse with Java for Android programming. In fact, I'm working on the first basic sample app in the tutorial at developer.android.com. I have the following activity_main.xml:
<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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
android:orientation="horizontal" >
<EditText android:id="@+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
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"
android:onClick="sendMessage" />
</LinearLayout>
and the following strings.xml
<?xml version="1.0" encoding="utf-8"? >
<resources>
<string name="app_name">My First App2</string>
<string name="edit_message">Enter a message</string>
<string name="button_send">Send</string>
<string name="action_settings">Settings</string>
<string name="title_activity_main">MainActivity</string>
<string name="title_activity_display_message">My Message</string>
<string name="hello_world">Hello world!</string>
</resources>
As you can see I have a button_send string and an edit_message string in strings.xml which are both referenced in activity_main.xml. However, a build yields the error "No resource found that matches the given name (at 'text' with value '@string/button_send')". Any ideas, please?
Upvotes: 3
Views: 996
Reputation: 10040
<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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
android:orientation="horizontal" >
You have an extra > in the second to last line of the opening to your LinearLayout
. Remove that character, clean your project, and that will probably fix the problem.
Upvotes: 2
Reputation: 523
Here are a couple ideas:
EDIT:
You can also go into the eclipse GUI for the XML file and right-click the button. Click "Edit Text", which should bring up your String values. You should be able to see button_send. If you don't, there's an issue with your strings.xml.
Upvotes: 3