150e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Mainpage.title=Input Controls
250e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Mainparent.title=User Interface
350e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Mainparent.link=index.html
450e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main@jd:body
550e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main
650e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main<div class="figure" style="margin:0">
750e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main  <img src="{@docRoot}images/ui/ui-controls.png" alt="" style="margin:0" />
850e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main</div>
950e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main
1050e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main<p>Input controls are the interactive components in your app's user interface. Android provides a
1150e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Mainwide variety of controls you can use in your UI, such as buttons, text fields, seek bars,
1250e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Maincheckboxes, zoom buttons, toggle buttons, and many more.</p>
1350e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main
1450e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main<p>Adding an input control to your UI is as simple as adding an XML element to your <a
1550e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Mainhref="{@docRoot}guide/topics/ui/declaring-layout.html">XML layout</a>. For example, here's a
1650e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Mainlayout with a text field and button:</p>
1750e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main
184a5425dbd29329aaffbab3bb83c33bd437958237Scott Main<pre style="clear:right">
1950e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main&lt;?xml version="1.0" encoding="utf-8"?>
2050e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2150e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main    android:layout_width="fill_parent"
2250e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main    android:layout_height="fill_parent"
2350e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main    android:orientation="horizontal">
2450e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main    &lt;EditText android:id="@+id/edit_message"
2550e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main        android:layout_weight="1"
2650e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main        android:layout_width="0dp"
2750e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main        android:layout_height="wrap_content"
2850e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main        android:hint="@string/edit_message" />
2950e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main    &lt;Button android:id="@+id/button_send"
3050e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main        android:layout_width="wrap_content"
3150e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main        android:layout_height="wrap_content"
3250e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main        android:text="@string/button_send"
3350e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main        android:onClick="sendMessage" />
3450e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main&lt;/LinearLayout>
3550e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main</pre>
3650e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main
3750e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main<p>Each input control supports a specific set of input events so you can handle events such as when
3850e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Mainthe user enters text or touches a button.</p>
3950e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main
4050e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main
4150e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main<h2 id="CommonControls">Common Controls</h2>
4250e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main<p>Here's a list of some common controls that you can use in your app. Follow the links to learn
4350e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Mainmore about using each one.</p>
4450e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main
4550e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main<p class="note"><strong>Note:</strong> Android provides several more controls than are listed
4650e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Mainhere. Browse the {@link android.widget} package to discover more. If your app requires a
4750e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Mainspecific kind of input control, you can build your own <a
4850e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Mainhref="{@docRoot}guide/topics/ui/custom-components.html">custom components</a>.</p>
4950e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main
5050e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main<table>
5150e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main    <tr>
5250e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main        <th scope="col">Control Type</th>
5350e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main        <th scope="col">Description</th>
5450e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main	<th scope="col">Related Classes</th>
5550e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main    </tr>
5650e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main    <tr>
5750e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main        <td><a href="controls/button.html">Button</a></td>
5850e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main        <td>A push-button that can be pressed, or clicked, by the user to perform an action.</td>
5950e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main	<td>{@link android.widget.Button Button} </td>
6050e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main    </tr>
6150e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main    <tr>
6250e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main        <td><a href="controls/text.html">Text field</a></td>
6350e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main        <td>An editable text field. You can use the <code>AutoCompleteTextView</code> widget to create a text entry widget that provides auto-complete suggestions</td>
6450e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main	<td>{@link android.widget.EditText EditText}, {@link android.widget.AutoCompleteTextView}</td>
6550e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main    </tr>
6650e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main    <tr>
6750e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main        <td><a href="controls/checkbox.html">Checkbox</a></td>
6850e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main        <td>An on/off switch that can be toggled by the user. You should use checkboxes when presenting users with a group of selectable options that are not mutually exclusive.</td>
6950e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main	<td>{@link android.widget.CheckBox CheckBox} </td>
7050e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main    </tr>
7150e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main    <tr>
7250e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main        <td><a href="controls/radiobutton.html">Radio button</a></td>
7350e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main        <td>Similar to checkboxes, except that only one option can be selected in the group.</td>
7450e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main	<td>{@link android.widget.RadioGroup RadioGroup} 
7550e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main	<br>{@link android.widget.RadioButton RadioButton} </td>
7650e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main    </tr>
7750e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main    <tr>
7850e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main        <td><a href="controls/togglebutton.html" style="white-space:nowrap">Toggle button</a></td>
7950e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main        <td>An on/off button with a light indicator.</td>
8050e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main	<td>{@link android.widget.ToggleButton ToggleButton} </td>
8150e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main    </tr>
8250e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main    <tr>
8350e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main        <td><a href="controls/spinner.html">Spinner</a></td>
8450e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main        <td>A drop-down list that allows users to select one value from a set.</td>
8550e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main	<td>{@link android.widget.Spinner Spinner} </td>
8650e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main    </tr>
8750e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main    <tr>
8850e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main        <td><a href="controls/pickers.html">Pickers</a></td>
8950e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main        <td>A dialog for users to select a single value for a set by using up/down buttons or via a swipe gesture. Use a <code>DatePicker</code>code> widget to enter the values for the date (month, day, year) or a <code>TimePicker</code> widget to enter the values for a time (hour, minute, AM/PM), which will be formatted automatically for the user's locale.</td>
9050e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main	<td>{@link android.widget.DatePicker}, {@link android.widget.TimePicker}</td>
9150e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main    </tr>
9250e990c64fa23ce94efa76b9e72df7f8ec3cee6aScott Main</table>
93