views:

1369

answers:

5

Hello,

I hope that I have come to the right post for a beginner’s question abut Android programming. If not, please feel free to direct me to a better forum.

I created a hello world application, and the system generated most of the Android language below. When running the app without the system.out statement, there is no “hello” in the emulator. Then, using the Eclipse tutorial, I read that I can add the system.out.println statement to main. Again the app runs, but there is no output.

What am I not understanding here?

android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" System.out.println =" Hello world!" />

Thank you,

Keith

+2  A: 

Beginners' questions are fine, but boy, this really is a beginner question :) As for your problem, it can be a few things. What's probably happened is that you've adapted the basic "Hello, Android" tutorial which defines the TextViews in code, to make it display using an XML file. However, when you did that, you didn't change the code to use that XML file, and instead it's trying to display your old TextView. Also, "System.out.println="hello world!" won't do anything when in your XML file - you need to put statements like that in the code itself. In fact, offhand I can't remember if System.out.... even does anything in Android - debugging lines should be issued using Log.d("some title", "your message"), as that outputs to the Android specific logging device.

Anyway, it'd be easier to help solve your problem if you showed a bit more of your code. Try to make sure it's formatted properly, e.g. indenting code lines by four spaces. You can preview your post before you submit your edited version in the lower window to make sure it looks right.

Steve H
thank you both, this is really helpful.
keith
+1  A: 

Try this.

Hardcoded in [your_layout].xml ... android:layout_width="fill_parent" android:layout_height="wrap_content" android:text=" Hello world" />

or this

Use reference in [your_layout].xml ... android:layout_width="fill_parent" android:layout_height="wrap_content"
android:text="@strings/hello" />

In res/values/strings.xml

<resources>
    <string name="hello">Hello world</string>
</resources>

That should help you get started a bit. A few thing to remember, System.out.println doesn't do a thing in Android, especially in XML file. When addressing text with "@string/hello", it means that the application will look for string name "hello" inside strings.xml.

Anyway, you should try Android tutorial to get start.

RobGThai
A: 

lol. Check this out. I go through this installation process and read about how easy this thing is to get up and running with a "Hello World" application. I run the simple hello world application (Exactly as it says) and POOF... nothing. I get an error java.lang.IllegalArgumentException: Bad version: standalone at com.android.sdkstats.sdkStatsService.normalizeVersion(sdkStatsService.java:467)

Any idea how to fix this?

Jerrod
A: 

I am getting the same exception. I see some posts that in Windows 7 there is some problem with the jre's in 32 bit and that 64 bit works:

http://www.questionhub.com/StackOverflow/3921242

But i am working on old Windows XP Pro and both jre 1.5.0.8 or 1.6.0.16 do not work. I cannot see the error that occurs in 1.6 (it goess too fast even while i am recording the screen) but I get the same error with 1.5.

I might try a vanilla machine later.

Francisco
A: 

One thing is for sure, putting println in your layout resource file won't do anything. This code(if it may be called so) is NOT executed. This is just definition of view. If at all, this statement should be called from your Activity class implementation(the java file) to be executed.

deeJ