#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2012
    Posts
    4
    Rep Power
    0

    Please help me get started!


    Hi, I'm a newbie; trying to get started with a simple hello world program to run on the emulator. I see the emulator with "ANDROID", but no "Hello, Android" text on the screen. I'm using Window 7 Home Premium edition, Android SDK for windows, Android 4.0 platform, Java SE 7u2, Eclipse IDE for Java Developers.

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TextView tv = new TextView(this);
    tv.setText("Hello, Android");
    setContentView(tv);
    }

    Please advise. Thanks.
  2. #2
  3. No Profile Picture
    Needs a pillow.... :)
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2006
    Posts
    681
    Rep Power
    91
    A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools. - Douglas Adams
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2012
    Posts
    3
    Rep Power
    0
    Originally Posted by myandroid
    Hi, I'm a newbie; trying to get started with a simple hello world program to run on the emulator. I see the emulator with "ANDROID", but no "Hello, Android" text on the screen. I'm using Window 7 Home Premium edition, Android SDK for windows, Android 4.0 platform, Java SE 7u2, Eclipse IDE for Java Developers.

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TextView tv = new TextView(this);
    tv.setText("Hello, Android");
    setContentView(tv);
    }

    Please advise. Thanks.
    you haven't linked your Text view to the xml reference.

    Textview tv = [TextView] findViewBy.Id(R.id.xmlidreference);

    in other words, the java can't tell which textview you are trying to change so nothing is happening
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2012
    Posts
    4
    Rep Power
    0
    I in fact used the hello example from your link. The code snippet from my last post does not work for me, but below works for me:

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    }

    Thanks for your reply.

IMN logo majestic logo threadwatch logo seochat tools logo