0

This is my first time working with the Android framework. I followed the guidelines on the Android page to make a test app. Even after doing exactly how they mention, I get errors like this (for clarity sake, I only mentioned few of them). I really can't figure out how to go from here.

[2013-06-21 08:46:37 - My First App] W/ResourceType( 7940): Bad XML block: header size 122 or total size 8002512 is larger than data size 0
[2013-06-21 08:46:37 - My First App] C:\Users\llp-admin\workspace3\My First App\res\layout\activity_main.xml:7: error: Error: No resource found that matches the given name (at 'hint' with value '@string/edit_message').

This is the activity_main.xml file:

<?xml version="1.0" encoding="utf-8"?>
<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_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" />
</LinearLayout>

This is the strings.xml file:

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">My First App</string>
    <string name="hello_world">Hello world!</string>
    <string name ="button_send">Send</string>
    <string name = "action_settings">Settings</string>
    <string name = "title_activity_main">MainActivity</string>

</resources>
4

7 回答 7

1

创建一个名为 edit_message 的字符串

于 2013-06-21T13:45:26.367 回答
1

似乎您正在使用未定义的字符串引用,请将以下内容添加到 strings.xml

<string name = "edit_message">Editing</string>

您用于编辑文本提示的值 -@string/edit_message无处可寻。

于 2013-06-21T13:46:16.703 回答
1

错误就在这里

(at 'hint' with value '@string/edit_message').

想要一些类似的东西

<string name = "edit_message">This is the hint</string>

添加到 .xml 文件中。

于 2013-06-21T13:47:16.927 回答
1

添加字符串.xml

 <string name = "edit_message">This is edit text</string>
于 2013-06-21T13:49:41.750 回答
0

错误在android:hint。您正在指定要转到 string.xml 的代码,并使用名称为 edit_message 的条目作为编辑文本框的提示。但在 string.xml 中没有名为 edit_message 的条目。所以添加,

<string name = "edit_message">This is the hint</string>

这将解决您的问题。

于 2013-06-21T15:03:52.093 回答
0

您应该定义您在 xml 文件中引用的每个字符串。在这里,在您的情况下,您已经引用了一个名为 edit_message 的字符串。

您一定知道@+id 代表将您的资源添加到R.java 文件。

所以你应该硬编码字符串

    android:hint="This is my hardcoded string"

或者您可以像这样保留引用并在包资源管理器中的 strings.xml 文件中定义字符串-->您的项目-->res-->values-->strings.xml 文件

    <string name = "edit_message">message You want to show</string>
于 2013-07-02T04:27:13.200 回答
0

添加

<string name="et_message"">Your String Here</string>

在您的 Strings.xml 文件中

于 2016-03-05T08:53:58.967 回答