What is Android Programming
- Download and Install JDK.
- Install Eclipse IDE
Click here to download Eclipse IDE for 32 bit windows.
Click here to download Eclipse IDE for 64 bit windows. - Install Android SDK Click here to download Android SDK for windows.
Click here to download Android SDK for Linux.
Click here to download Android SDK for Mac.
- First Open the Eclipse IDE.
- In Eclipse, select File > New > Project.
- Select “Android Project” and click next.
Now fill following Details of your new project.
- Project Name: HelloAndroid
- Build Target: Select a platform version that is equal to or lower than the target you chose for your AVD.
- Application name: Hello Android
- Package Name: com.example.helloandroid
- Create Activity: HelloAndroid
and Then Click on Finish.
Then you are ready to do code in your android application now you search HelloAndroid.java from the left explorer tab in Eclipse IDE. It should be in HelloAndroid > src > com.example.helloandroid.
Once you find the select the file now the source file is open in front of you with some little inbuilt code. It looks like this.
import android.app.Activity;
import android.os.Bundle;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
If you are familiar with java then you can understand it quickly. In above code the Activity is class which contains many functions which is used to perform actions. OnCreate() method is initiated when the Android app starts. It is where you can perform many initialization functions and task.
Now let’s move to next step and will add some line to above code to print “Hello world” on screen.
import android.os.Bundle;
import android.widget.TextView;public class HelloAndroid 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. Welcome To My Android Apps”);
setContentView(tv);
}
}
TextView():- It is a class in android package used to handle the text formatting.
setText() :- it is a class in android package used to set the position and text on screen.
setContentView():- used to display the content on screen.
Now after the code just Run the program by following steps given below:
Here you done and successfully executed your first android application.
Nice tutorial thanks for posting.
I hope it will work for me!