java.lang.Object | ||
↳ | com.neomades.ui.View | |
↳ | com.neomades.ui.Switch |
Switch component shows an On/Off button.
The user manipulates this component by dragging horizontally the slider part ("flips" it).
You can customize the appearance of the switch by changing the on/off texts, and colors.
By default, the following properties are applied to a new TimePicker:
MATCH_CONTENT.
MATCH_CONTENT.
HCENTER|VCENTER.
toggle button
in older
versions (before API Level 14), otherwise it shows the
Holo switch
.XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Attribute Name | Related Method | Description | |||||||||
checked | setChecked(boolean) | To check the checkbox | |||||||||
checkedColor | setCheckedColor(Color) | #AARRGGBB or a color | |||||||||
contentAlignment | setContentAlignment(int) | A combination of alignment values (eg: TOP|LEFT) | |||||||||
defaultText | setDefaultText(String) | Res.string.XXXX or a text | |||||||||
font | setFont(Font) | Font resource id: Res.font.FONT_XXXX | |||||||||
textColor | setTextColor(Color) | #AARRGGBB or a color | |||||||||
textOff | setTextOff(String) | Res.string.XXXX or a text | |||||||||
textOn | setTextOn(String) | Res.string.XXXX or a text | |||||||||
textSize | setTextSize(int) | a size in dp |
[Expand]
Inherited XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Switch()
Construct a new Switch or Toggle (old version of android)
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
boolean | isChecked() | ||||||||||
void |
setCheckChangedListener(CheckChangedListener checkChangedListener)
Registers a callback to be invoked when the checked state of this switch
changes.
| ||||||||||
void |
setChecked(boolean checked)
Change the checked state of the view to on (
true ) or off (
false ). | ||||||||||
void |
setCheckedColor(Color color)
Sets the color of the Switch when it is checked.
| ||||||||||
void |
setContentAlignment(int alignment)
Sets the alignment of the text in the Switch.
| ||||||||||
void |
setDefaultText(String text)
Sets the default text of the Switch.
| ||||||||||
void |
setDefaultText(int resId)
Sets the default text of the Switch.
| ||||||||||
void |
setFont(Font font)
Sets the Switch text font.
| ||||||||||
void |
setTextColor(Color color)
Sets the Switch's text color.
| ||||||||||
void |
setTextOff(String off)
Sets the text displayed when the button is not in the checked state.
| ||||||||||
void |
setTextOff(int resId)
Sets the text displayed when the button is in the unchecked state.
| ||||||||||
void |
setTextOn(int resId)
Sets the text displayed when the button is in the checked state.
| ||||||||||
void |
setTextOn(String on)
Sets the text displayed when the button is in the checked state.
| ||||||||||
void |
setTextSize(int sizeInDp)
Sets the text size to a given value (in dp).
| ||||||||||
void |
toggle()
Change the checked state of the view to the inverse of its current state.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
A combination of alignment values (eg: TOP|LEFT)
Construct a new Switch or Toggle (old version of android)
on
Registers a callback to be invoked when the checked state of this switch changes.
checkChangedListener | the callback to be called or null to unregister
|
---|
Change the checked state of the view to on (true
) or off (
false
).
checked | true to change the state to on |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Sets the color of the Switch when it is checked.
color | the color of the Switch in the checked state |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|---|
NullPointerException | if the color parameter is null |
Sets the alignment of the text in the Switch. The parameter is a combination
of values from Alignment
alignment | The new alignment of the button's text |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Sets the default text of the Switch.
This method has an effect only in Android.
text | the label string |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Sets the default text of the Switch.
This method has an effect only in Android.
resId | the string resource id |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Sets the Switch text font.
font | new font for the text |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|---|
NullPointerException | if the font parameter is null |
Sets the Switch's text color.
color | new color for the text |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|---|
NullPointerException | if the parameter is null |
Sets the text displayed when the button is not in the checked state.
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Sets the text displayed when the button is in the unchecked state.
resId | the string resource id |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Sets the text displayed when the button is in the checked state.
resId | the string resource id |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Sets the text displayed when the button is in the checked state.
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Sets the text size to a given value (in dp).
sizeInDp | size to set to the text |
---|
Change the checked state of the view to the inverse of its current state.
CrossThreadException | if the method is called from outside the UI-Thread |
---|