• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Hello World newbie problem

Hi, this is my Hello World project but did not get it right:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is my first Android Application!" />

<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="And this is a clickable button!" />

</LinearLayout>

I can run this without problem but did not get the text and button showed up.

Also for these 2 lines:
android:text="This is my first Android Application!"
android:text="And this is a clickable button!"

Inside the Eclipse they are underlined.
Anything wrong?
 
Unless I am overlooking something, I am not seeing anything wrong.
Have you tryed cleaning your project? What does it say under the problems tab of the console?

EDIT: Just to be sure, does your strings.xml file have the hello string defined?
 
Unless I am overlooking something, I am not seeing anything wrong.
Have you tryed cleaning your project? What does it say under the problems tab of the console?

EDIT: Just to be sure, does your strings.xml file have the hello string defined?

When I moved my cursor over the line, it says:
[I18N] Hardcoded string "And this is a clickable button!", should use @string resource

I followed a book example, it does say anything about strings.xml.
When can I find it?

Sorry as I am very, very new to Android development area.
 
Hi ManUtdFans, I'm also very new to making apps, I started using some youtube videos, they're probably not as good as a book but these ones did cover strings in xml.

Android Tutorial & Lessons 1: Installing Eclipse and SDKs - YouTube

Android Application Development Tutorial - 1 - Download and Install the Java JDK - YouTube

These are both episode one of two different series by the same guy, whichever you choose you'll probably have to skip a couple of tutorials as the first ones are just about installing Eclipse etc.

Hope they're of some help but I would stick with your book on the whole (I need to get one which are you using?)
 
When I moved my cursor over the line, it says:
[I18N] Hardcoded string "And this is a clickable button!", should use @string resource

I followed a book example, it does say anything about strings.xml.
When can I find it?

Sorry as I am very, very new to Android development area.

the line about using hardcoded strings is simply a warning. hardcoding is entirely acpetable.

With that said, you mentioned that you didn't know what (or where) the strings XML file is, yet you reference it in your XML file with "@string/hello".

When you make use of hte '@' character in an XML name-value pair, it searches the values folder in the res directory of your project for the existence of that value.

Try either (a) hardcoding that string, or (b) enuring the line
Code:
<string name="hello">Hello World, NetActivity!</string>
is in between the <resources> tags inside the file <PROJECT DIR ROOT>/res/values/strings.xml
 
Back
Top Bottom