Want to Learn Hello World Tutorial in More Detail

This is a discussion on Want to Learn Hello World Tutorial in More Detail within the Beginning Developers forums, part of the Android Development category; I did the famous hello world tutorial Code : package com.mysite.helloworld;import android.app.Activity;import android.os.Bundle;import android.widget.TextView;public class MysitehelloworldActivity extends Activity { /** Called when the activity is ...

Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By Andrizzle

Thread: Want to Learn Hello World Tutorial in More Detail

  1. #1
    Android Lurker ketanco's Avatar
    Join Date
    Sep 2011
    Posts
    2

    Want to Learn Hello World Tutorial in More Detail

    I did the famous hello world tutorial

    Code:

    package com.mysite.helloworld;import android.app.Activity;import android.os.Bundle;import android.widget.TextView;public class MysitehelloworldActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText("Hello, Android"); setContentView(tv); }}

    and then it printed "Hello Android" with no problems on the virtual device.

    Now I want to print "Good Bye Android" also, in addition to, and below "Hello Android". Ho can I do it? I tried adding another line of tv.setText("Good Bye Android"); below the Hello Andorid line but this time it only displays Good bye Android. How can I make both displayed?

  2. Android.net is the premier Android Forum. Registered users do not see these ads. .

  3. #2
    Android Lurker Andrizzle's Avatar
    Join Date
    Oct 2011
    Posts
    1
    Thanked
    1 times
    Do you have any experience in Java? if not then the following wouldnt make any sense.

    I'm a noob to Android myself so I dont know if its entirely correct

    TextView is a class in widget that is used to well, see text, and "tv" is an instantiation of TextView with parameter "this."

    the setText() is a method I assume in TextView which takes a String parameter, and setContentView() is another method that is which is used to show what ever TextView objects you made, which is why "tv" is a parameter in the setContentView method.

    From what i deduce the code to type "Good bye android" alongside each other, you would create a second file printing "Goodbye android" have to use the "Intent" and the code format is likethis:

    Intent intent = new Intent ("name of the file youre coming from", "name of the file youre gonna end up in")
    startActivity(intent)
    for example:

    Intent intent = new Intent(File A, File B);
    startActivity(intent);


    but you also have to change one stuff in the XML files as well (if there is any)

    Hoped this helped
    alostpacket likes this.

  4. #3
    App Developer alostpacket's Avatar
    Join Date
    Jan 2011
    Location
    NY
    Posts
    240
    Thanked
    32 times
    Twitter
    alostpacket
    add a newline character "\n"

  5. #4
    Android Lurker hscoder's Avatar
    Join Date
    Apr 2012
    Posts
    4
    i think you can find all details of 'hello World' example on Android developers site.
    You can define your string in stings.xml that is located in res-->values in package explorer.
    You can create a resource element object that contain your string 'Good bye Android' with any name( such as 'myStr'). then you can use the following

    v.setText("@strings/myStr);

    But you can find another simple example with better explanation on here first Android project

    Thanks

    If you any problem the let me know

Remove Ads

http://www.scramblerducati.org/

Sponsored Links

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Similar Threads

  1. I'm new and eager to learn and help
    By puckgetter in forum Introductions & Site Assistance
    Replies: 2
    Last Post: 02-10-2012, 12:12 PM
  2. Learn Tamil pronunciation
    By appmaiyam in forum Android Forum
    Replies: 0
    Last Post: 12-03-2011, 09:21 PM
Android Forum