"Hello World" Android Tutorial/Setting up Emulator

Discussion in 'Archives' started by db0winsanity, Aug 5, 2010.

"Hello World" Android Tutorial/Setting up Emulator
  1. Unread #1 - Aug 5, 2010 at 4:04 AM
  2. db0winsanity
    Joined:
    Dec 28, 2008
    Posts:
    109
    Referrals:
    0
    Sythe Gold:
    0

    db0winsanity Active Member

    "Hello World" Android Tutorial/Setting up Emulator

    "Hello World" Android Tutorial/Setting up Emulator

    Difficulty: 1/10, follow me guide

    Overview: This Hello World tutorial, is being written so that you will learn the basics (and I mean basics) of Android development. Also in this tutorial, you will learn how to set up an Emulator so you can see the application you've made!

    Before starting this guide I am assuming you read, and completed the Guide Setting up Eclipse for Android Development (windows)

    Goals in this Tutorial:
    • Setting up the Project
    • Constructing the User Interface
    • Running the application/setting up the emulator

    Part I: Setting up the Project
    1) Go to File > New > Project...

    2) Click the arrow next to Android, then select Android Project
    [​IMG]

    3) Fillout the form that's on your screen
    • Set the project name as HelloWorld
    • check Android 1.5
    • Set Application name as Hello World
    • Set Package name as com.helloworld
    • Make sure Create Activity is checked and name it helloWorld
    • Min SDK version = 3
    [​IMG]

    4) Click finish

    Part II: Constructing the User interface.
    1) open your class its in your src folder, click:
    • src
    • com.helloworld
    • double click helloworld.java

    Now that your class is open, it should look like this:
    Code:
    package com.helloworld;
    
    import android.app.Activity;
    import android.os.Bundle;
    
    public class helloWorld extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
        }
    }
    2) now, we're going to add a TextView, which shows us text on the screen of the android phone

    • You now want your code to look like this:
    Code:
    package com.example.helloandroid;
    
    import android.app.Activity;
    import android.os.Bundle;
    [B]import android.widget.TextView;[/B]
    
    public class HelloAndroid extends Activity {
       /** Called when the activity is first created. */
       @Override
       public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
          [B] TextView tv = new TextView(this);
           tv.setText("Hello, Android");
           setContentView(tv);[/B]
       }
    }
    
    Part III: Running the application/setting up the emulator.
    1) go to Window > Android SDK and AVD manager
    2) now, click on new, on the right side of the screen.
    3) Call it "Emulator" or whatever you'd like
    4) change target to Android 1.5 - API level 3
    4) click on "create AVD"
    5) Close window

    6) now, to run the program, its pretty simple, go to Run > run last launched
    7) a dialog will pop up, choose android application


    Your finished! this is what it should look like when you're all done! congratz you finished your first android program!
    [​IMG]

    *note, you do not need to re setup the emulator in every program, just this once*

    I will be continueing these tutorials (Android) at some point, its late, and its not getting done now, but check back often! they'll be here!

    Next tutoral: Simple adding Machine!
     
< Need help being booted in doubles | Setting up Eclipse for Android Development (windows) >

Users viewing this thread
1 guest


 
 
Adblock breaks this site