Android Programming Tutorials

(Romina) #1
Getting More Active

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="1"
>
<TableRow>
<TextView android:text="Name:" />
<EditText android:id="@+id/name" />
</TableRow>
<TableRow>
<TextView android:text="Address:" />
<EditText android:id="@+id/addr" />
</TableRow>
<TableRow>
<TextView android:text="Type:" />
<RadioGroup android:id="@+id/types">
<RadioButton android:id="@+id/take_out"
android:text="Take-Out"
/>
<RadioButton android:id="@+id/sit_down"
android:text="Sit-Down"
/>
<RadioButton android:id="@+id/delivery"
android:text="Delivery"
/>
</RadioGroup>
</TableRow>
<TableRow>
<TextView android:text="Notes:" />
<EditText android:id="@+id/notes"
android:singleLine="false"
android:gravity="top"
android:lines="2"
android:scrollHorizontally="false"
android:maxLines="2"
android:maxWidth="200sp"
/>
</TableRow>
<Button android:id="@+id/save"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Save"
/>
</TableLayout>

This is just the detail form turned into its own standalone layout file.


Next, un-comment the setContentView() call in onCreate() in DetailForm and


have it load this layout:


setContentView(R.layout.detail_form);

112
Free download pdf