| java.lang.Object | ||
| ↳ | com.neomades.ui.View | |
| ↳ | com.neomades.ui.RadioButton | |
A RadioButton is a two states item (checked, unchecked).
However, unlike CheckBox, items cannot be unselected by the user once
checked. RadioButtons are normally used into RadioGroup.
In that case, their state are linked and only one item can be checked at a
time.
Note that a RadioButton is not necessarily part of a
RadioGroup: it can be added directly to a layout.
In Android, a RadioButton is a
android.widget.RadioButton. It is composed of an image, for
which the visual aspect changes if the button is checked or unchecked, and a
text at the right of the image.
In iOS, a RadioButton is a UITableViewCell inside a
UITableViewController. A check mark is drawn at the right of the
button text to indicate if the item is checked or not. The mark is inside the
cell.
| XML Attributes | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Attribute Name | Related Method | Description | |||||||||
| checked | setChecked(boolean) | To check the checkbox | |||||||||
| font | setFont(Font) | Font resource id: Res.font.FONT_XXXX | |||||||||
| text | setText(int) | Res.string.XXXX or a text | |||||||||
| textColor | setTextColor(Color) | #AARRGGBB or a color | |||||||||
| textSize | setTextSize(int) | a size in dp | |||||||||
|
[Expand]
Inherited XML Attributes | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
com.neomades.ui.View
| |||||||||||
|
[Expand]
Inherited Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From interface
com.neomades.ui.Alignment
| |||||||||||
From interface
com.neomades.ui.StretchMode
| |||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
RadioButton()
Constructs a new
RadioButton, with no text and unchecked. | |||||||||||
|
RadioButton(String text)
Constructs a new
RadioButton, with the given text and unchecked. | |||||||||||
|
RadioButton(String text, boolean checked)
Constructs a new
RadioButton, with the given text and the given
checked state. | |||||||||||
|
RadioButton(int resId)
Constructs a new
RadioButton, with the given text and unchecked. | |||||||||||
|
RadioButton(int resId, boolean checked)
Constructs a new
RadioButton, with the given text and the given
checked state. | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| RadioGroup | getRadioGroup() | ||||||||||
| String |
getText()
Returns the current text of the radio button.
| ||||||||||
| boolean |
isChecked()
Returns the current state of the
RadioButton. | ||||||||||
| void |
setCheckChangedListener(CheckChangedListener listener)
Sets a listener that will listen for the state of the radio button (checked
or unchecked).
| ||||||||||
| void |
setChecked(boolean checked)
Sets the state of the
RadioButton to checked or unchecked. | ||||||||||
| void |
setFont(Font font)
Sets the radio button text font.
| ||||||||||
| void |
setText(String text)
Sets the text of this
RadioButton. | ||||||||||
| void |
setText(int resId)
Sets the text of this
RadioButton. | ||||||||||
| void |
setTextColor(Color color)
Sets the text color of this radio button's text.
| ||||||||||
| void |
setTextSize(int sizeInDp)
Sets the text size to a given value (in dp).
| ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
com.neomades.ui.View
| |||||||||||
From class
java.lang.Object
| |||||||||||
Constructs a new RadioButton, with no text and unchecked.
Constructs a new RadioButton, with the given text and unchecked.
| text | the radio button's text |
|---|
Constructs a new RadioButton, with the given text and the given
checked state.
| text | the radio button's text |
|---|---|
| checked | the checked state |
Constructs a new RadioButton, with the given text and unchecked.
| resId | the string id assigned to this radio button text |
|---|
Constructs a new RadioButton, with the given text and the given
checked state.
| resId | the string id assigned to this radio button text |
|---|---|
| checked | the checked state |
Returns the RadioGroup of the RadioButton (
null if the button has not yet been added to a group).
RadioGroup of this RadioButton or
null if the button is not yet into a group
Returns the current text of the radio button. Returns an empty string ("") if there is no text.
Returns the current state of the RadioButton.
true if the button is checked, false
otherwise
Sets a listener that will listen for the state of the radio button (checked
or unchecked). When the state changes,
onCheckChange(View, boolean) of the listener is
called with the RadioButton and its new state as parameters.
| listener | listener CheckChangedListener
|
|---|
Sets the state of the RadioButton to checked or unchecked.
| checked | new state of the RadioButton : true for
checked, false for unchecked |
|---|
| CrossThreadException | if the method is called from outside the UI-Thread |
|---|
Sets the radio button 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 text of this RadioButton.
| text | the new text |
|---|
| CrossThreadException | if the method is called from outside the UI-Thread |
|---|
Sets the text of this RadioButton.
| resId | the string id assigned to this radio button text |
|---|
| CrossThreadException | if the method is called from outside the UI-Thread |
|---|
Sets the text color of this radio button's text.
| color | the color to set (with the alpha channel) |
|---|
| 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 |
|---|