robinhood91
robinhood91

Reputation: 1691

Android beginner issue

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>

Upvotes: 0

Views: 196

Answers (7)

WaQas
WaQas

Reputation: 11

Add

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

in your Strings.xml file

Upvotes: 0

viedee
viedee

Reputation: 1657

You should define each and every String to which you give the reference in your xml file. Here, in your case you have given reference to a String called edit_message.

You must be knowing that @+id stands for adding your resource to the R.java file.

So you should either hardcode the string

    android:hint="This is my hardcoded string"

or you can keep reference like you have kept and define the string in strings.xml file in package explorer-->your project-->res-->values-->strings.xml file like this

    <string name = "edit_message">message You want to show</string>

Upvotes: 0

Dulanga
Dulanga

Reputation: 1346

The error is at android:hint. you are specifying the code to go to string.xml and use the entry with the name edit_message as the hint for your Edit text box. But there is no entry called edit_message in string.xml. So add,

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

This will solve your problem.

Upvotes: 0

Sunil Kumar
Sunil Kumar

Reputation: 7092

add in string.xml

 <string name = "edit_message">This is edit text</string>

Upvotes: 1

WeldFire
WeldFire

Reputation: 304

The error right here

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

is wanting something along the lines of

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

added to the .xml file.

Upvotes: 1

Shark
Shark

Reputation: 6610

It seems like you're using an undefined string reference, add the following to the strings.xml

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

The value you use for your edittext's hint - @string/edit_message is nowhere to be found.

Upvotes: 1

samleighton87
samleighton87

Reputation: 579

make a string called edit_message

Upvotes: 1

Related Questions