Let's have our first Android Application. Open your Eclipse software. Then go to FILE >>> NEW >>> PROJECT, then select ANDROID NEW APPLICATION. Then a dialog box will pop out. Fill in the textbox as follows:
Then click Next.
So we have here the dialog box to configure our launcher icon for the app, just play around, look for a good icon, change the scale, shape or background. Or if you don't need that, just click Next.
Click Next.
Then you can change the name of the Activity, but in my case, I didn't change it.
If your created the project, you will have the interface of Eclipse like this one below.
The MainActivity.java is the main activity code. From the image below, it is located inside src>>>com.example.helloworld.
This is the actual code wherein converted into a executable file and runs your application. Below is the example code for the MainActivity.java.
Any component you develop in your application, you must first declare the components in a manefest file, which is called as the AndroidManifest.xml. It is located below res folder.
The AndroidManifest.xml will serve as your interface of your application and the Android OS. If you did not declare your component in this file, then the OS will not consider it. Below is a sample code for AndroidManifest.xml.
Next, we have hrere the Strings file and also known as Strings.xml. Located inside res folder, then in values folder. Double click on it to open.
The names of labels, text, button go into this file. It is responsible for the textual content.
Next, we have here the R.java. It is considered as a glue between the activity Java files like the MainActivity.java and the resources like strings.xml. This file is automatically generated and remember not to modify this file. Never modify this file! Here is an example code of R.java.
And last, the Layout file. in our case, fragment_main.xml is our layout file. Modifying this file frequently is changing the layout of your application. Below is an example of the code.
Then, let us try to un our program "Hello World". In creating AVD just click here (AVD Tutorial). To run the application from Eclipse, open one of the project's activity files and click on Run button. It looks like this.
Then Eclipse install your app to the AVD and starts it and it will display your application.
Hooray! You just developed your first Android Application.
0 (mga) komento:
Post a Comment