0% found this document useful (0 votes)
18 views20 pages

Android Lecture5

RadioButtons should be placed inside a RadioGroup to ensure only one can be selected at a time. The RadioGroup exposes functions to programmatically select and get the currently selected RadioButton. RadioButtons can also have click listeners added directly. Spinners provide a dropdown selection box with radio button options for space savings over multiple radio buttons. Setting up a spinner requires an array of choices, an ArrayAdapter to format the array, and associating the adapter with the spinner. Checkboxes generate click events and their state can be checked with the isChecked() method. EditTexts allow text entry and can constrain input type. Seekbars allow integer value selection with a slider and sense touch initiation, ending,

Uploaded by

Jb Santos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views20 pages

Android Lecture5

RadioButtons should be placed inside a RadioGroup to ensure only one can be selected at a time. The RadioGroup exposes functions to programmatically select and get the currently selected RadioButton. RadioButtons can also have click listeners added directly. Spinners provide a dropdown selection box with radio button options for space savings over multiple radio buttons. Setting up a spinner requires an array of choices, an ArrayAdapter to format the array, and associating the adapter with the spinner. Checkboxes generate click events and their state can be checked with the isChecked() method. EditTexts allow text entry and can constrain input type. Seekbars allow integer value selection with a slider and sense touch initiation, ending,

Uploaded by

Jb Santos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Android Programming

Lecture 5
9/16/2011
RadioButtons
Multiple RadioButtons
belong in a RadioGroup
RadioGroup
Manages only-one-
selected
Exposes functions to:
programmatically select a
button via ID
determine ID of button
currently selected
RadioButtons

This is not explicitly using the Listener pattern


for the RadioButtons (not responding to the
click; just checking what is clicked)
RadioButtons
Can also listen directly
to clicks on
RadioButtons
Spinner
Drop-down selection box, with a list of
RadioButton options
Provides screen real-estate savings over multiple
individual RadioButtons
Requires a different approach to setup
An array of choices to present
An ArrayAdapter to format the array data for the
Spinner
The actual Spinner view component, associated with
the ArrayAdapter
Spinner
Spinner

Setup prompt at top of pop-up that appears

Set up array

Associate adapter with array


and spinner with adapter
Spinner: Listening for Selection Events
in Spinner
Spinner: Listening for Selection Events
in Spinner
Wait a Minute!

Set up array

Isnt this dealing with


setting up the interface, in the code?
Can I make this an XML resource too?
CheckBox
2-state toggles (on/off)
Not organized in a group
Some, all, or none can be checked in a logical
group
Generates Click events
A Click event only says a click happened: Need to
be able to check state of CheckBox
Call boolean isChecked() method on CheckBox
CheckBox
EditText
Allows entry of arbitrary text from physical or
virtual keyboard

Typically end of entry is signified by


Associated button being clicked OR (a Click event)
Return being pressed in the editable field (a
KeyPress event)

Can constrain to only certain types of input


EditText
EditText
Edit Text: Constraining Type

Even more: developer.android.com/reference/android/text/InputType.html


EditText: Constraining Type

Password type -> hides


each letter after it is typed
SeekBar
SeekBar (slider) allow
selection of integer
values using a natural
interface
Constraints:
Min: 0
Max: settable
Changes by: 1
Starting point for knob
can be set
Senses initiation of
touch ,ending of touch,
and movement
SeekBar
SeekBar

You might also like