Lab 3
Lab 3
Basic Widgets
By
M.Zakir Khan
Activity Implementing the onClickListener Interface
XML code and JAVA code
Displaying Message through Toast
Using the EditText Control
• The Edittext is the subclass of TextView and is used for getting input
from the user.
• Several attributes can be used to configure the Edittext to suit your
requirements.
• For example We can implement the scrolling feature to scroll the text when
user type beyond the width or auto text feature to correct common spelling
mistake.
Attributes used to configure the EditText Control
Try it Now
android:layout_width (the two valid values are wrap_content and
match parent)
android:layout_height (the two valid values are wrap_content and
match parent)
android:singleLine (when set to true, forces the Edittext control to
remain on single line and when set false then the cursor move to the
next line)
android:hint (Displaying helpul text to guide the user during entry)
android:lines (when we set android:lines=“5” set the Edittext height
control to accommodate to five lines)
android:textSize (set the size of text typed inEdittext control)
Attributes used to configure the EditText Control
Try it Now
android:autoText (When set true enables the edittext control to
correct common spelling mistakes)
android:capatalize (Automatically convert the typed text into capital
letters)
android:password (it hide the enter text to dot)
android:minWidth (specify the minimum width of the control)
android:maxHeight
android:maxWidth
android:scrollHorizontally (make the text scroll hoirzontally)
Android:inputType
• Specify the type of data that will be type in Edittext control.
• This attribute configure the onscreen keyboard too.
• There are many possible values that include
• Number
• Phone
• Text
• textCapCharacters
• textCapWords
• textEmailAddress
• dateTime
• Date
• Time
• textAutoCorrect
• textMultiLine
• textPassword
Adding EventListener to Edittext Control
XML code and Java code
Input Control Button
• We can represent the Button on three different way like shown
CheckBox control
XML and JAVA code
Checkbox (Example 2)
XML Code
Java Code
Radio Button
XML and JAVA code
Radio Button
XML and JAVA code
Radio Button Example 2 Task