
View elements consist of familiar UI elements, including:
• Button
• ImageButton
• EditText
• TextView (similar to a label)
• CheckBox
• Radio Button
• Gallery and ImageSwitcher for displaying multiple images
• List
• Grid
• DatePicker
• TimePicker
• Spinner (similar to a combo box)
• AutoComplete (EditText with auto text-complete feature)
Views are defined in an XML file. Listing 3 shows an example of a simple
LinearVertical layout.
Listing 3. Simple LinearVertical layout
<?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="Activity 1!"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Activity 1, second text view!"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Switch To Activity 2"
id="@+id/switchto2"
/>
</LinearLayout>
developerWorks® ibm.com/developerWorks
Develop Android applications with Eclipse
Page 8 of 35 © Copyright IBM Corporation 1994, 2008. All rights reserved.
Comentários a estes Manuais