Android Programming Tutorials

(Romina) #1
A Simple Form

Outside of Eclipse


Inside your terminal (e.g., Command Prompt for Windows), switch to a


directory in which you would like the project to reside. Then, run the


following command:


android create project --target "Google Inc.:Google APIs:6" --path ./LunchList
--activity LunchList --package apt.tutorial

This will create an application skeleton for you, complete with everything


you need to start building the LunchList application.


Step #2: Modify the Layout..................................................................


Using your text editor, open the LunchList/res/layout/main.xml file.


Initially, that file will look like this:


<?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="Hello World, LunchList"
/>
</LinearLayout>

Change that layout to look like this:


<?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"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"

12
Free download pdf