Android Tutorial

(avery) #1

By : Ketan Bhimani


172 

Clickable AutoLinks: URL launches browser, phone number
launches dialer, and street address launches Google Maps.

Retrieving Text Input Using EditText Controls

The Android SDK provides a convenient control called EditText to
handle text input from a user. The EditText class is derived from
TextView. In fact, most of its functionality is contained within
TextView but enabled when created as an EditText.The EditText
object has a number of useful features enabled by default, many of
which are shown in Figure.

First, though, let’s see how to define an EditText control in an XML
layout file:

<EditText
android:id=”@+id/EditText01”
android:layout_height=”wrap_content”
android:hint=”type here”
android:lines=”4”
android:layout_width=”fill_parent” />


This layout code shows a basic EditText element. There are a
couple of interesting things to note. First, the hint attribute puts
Free download pdf