Creating Your First Application 2
We will complete previous lesson Creating Your First Application1 , in the last step in previous lesson the figure below explain that step
6. The main.xml file defines the user interface (UI) of your application. The default view is the Layout view, which lays out the activity graphically. To modify the UI, click the main.xml tab located at the bottom
7 Add the following code in bold to the main.xml file:
<?xml version=”1.0” encoding=”utf-8”?>
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:orientation=”vertical”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent” >
<TextView
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:text=”@string/hello” />
<TextView
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:text=”This is my first Android Application!” />
<Button
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:text=”And this is a clickable button!” />
</LinearLayout>
8 To save the changes made to your project, press Ctrl+s.
9 You are now ready to test your application on the Android Emulator. Select the project name in Eclipse and press F11. You will be asked to select a way to debug the application. Select Android Application as shown in Figure and click OK.
10. The Android Emulator will now be started (if the emulator is locked, you need to slide the unlock button to unlock it first). Figure 1-26 shows the application running on the Android Emulator.
11. Click the Home button (the house icon in the lower-left corner above the keyboard) so that it now shows the Home screen (see Figure)
12. Click the application Launcher icon to display the list of applications installed on the device. Note that the HelloWorld application is now installed in the application launcher (see Figure)
How It Works
To create an Android project using Eclipse, you need to supply the information shown in Table
Table : Project Files Created by Default
properties Description
Project name The name of the project
Application name A user-friendly name for your application
Package name The name of the package You should
use a reverse domain name for this
Create Activity The name of the fi rst activity in your application
Min SDK Version The minimum version of the SDK that your project is targeting
0 التعليقات:
Post a Comment