public class Radio extends Control implements TextControl, MaterialEffect.SideEffect
Here is an example showing a radio being used:
public class MyProgram extends MainWindow
{
RadioGroupController rgGender;
public void initUI()
{
rgGender = new RadioGroupController();
add(new Radio("Male", rgGender), LEFT, AFTER);
add(new Radio("Female", rgGender), AFTER+2, SAME);
rgGender.setSelectedIndex(radioMale); // activate the specified one.
}
public void onEvent(Event event)
{
if (event.type == ControlEvent.PRESSED && (event.target instanceof Radio) && ((Radio)event.target).getRadioGroup() == rgGender)
{
boolean male = rgGender.getSelectedIndex() == 0;
... handle radio Male being pressed
RadioGroupControllerControl.TranslucentShape| Modifier and Type | Field and Description |
|---|---|
boolean |
autoSplit |
int |
checkColor
Set to the color of the check, if you want to make it different of the foreground color.
|
boolean |
leftJustify
Set to true to left justify this control if the width is above the preferred one.
|
int |
textColor
Sets the text color of the check.
|
AFTER, alphaValue, appId, appObj, asContainer, asWindow, backColor, BEFORE, BOTTOM, BOTTOM_OF, BRIGHTER_BACKGROUND, callListenersOnAllTargets, CENTER, CENTER_OF, clearValueInt, clearValueStr, DARKER_BACKGROUND, DP, effect, enableUpdateScreen, esce, eventsEnabled, FILL, fillColor, FIT, floating, fm, fmH, focusHandler, focusLess, focusOnPenDown, focusTraversable, font, FONTSIZE, foreColor, height, ignoreInsets, isHighlighting, isTablet, KEEP, keepDisabled, keepEnabled, LEFT, next, nextTabControl, npParts, offscreen, offscreen0, onEventFirst, parent, PARENTSIZE, PARENTSIZEMAX, PARENTSIZEMIN, PREFERRED, prev, RANGE, repositionAllowed, RIGHT, RIGHT_OF, SAME, SCREENSIZE, SCREENSIZEMAX, SCREENSIZEMIN, setFont, setH, setRel, setW, setX, SETX_NOT_SET, setY, tempW, textShadowColor, TOP, translucentShape, transparentBackground, uiAdjustmentsBasedOnFontHeightIsSupported, uiAndroid, UICONST, uiFlat, uiHolo, uiMaterial, uiVista, visible, width, WILL_RESIZE, x, y| Constructor and Description |
|---|
Radio(java.lang.String text)
Creates a radio control displaying the given text.
|
Radio(java.lang.String text,
RadioGroupController radioGroup)
Creates a radio control with the given text attached to the given RadioGroupController
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears this control, checking it if clearValueInt is 1.
|
int |
getPreferredHeight()
returns the preferred height of this control.
|
int |
getPreferredWidth()
returns the preferred width of this control.
|
RadioGroupController |
getRadioGroup()
Returns the RadioGroupController that this radio belongs to, or null if none.
|
int |
getRadioTextGap()
The gap between the radio and the text.
|
java.lang.String |
getText()
Gets the text displayed in the radio.
|
boolean |
isChecked()
Returns the checked state of the control.
|
protected void |
onBoundsChanged(boolean screenChanged)
Called after a setRect.
|
protected void |
onColorsChanged(boolean colorsChanged)
Called after a setEnabled, setForeColor and setBackColor and when a control has
been added to a Container.
|
void |
onEvent(Event event)
Called by the system to pass events to the radio control.
|
protected void |
onFontChanged()
Called after a setFont
|
void |
onPaint(Graphics g)
Called by the system to draw the radio control.
|
void |
setChecked(boolean checked)
Sets the checked state of the control.
|
void |
setChecked(boolean checked,
boolean sendPress)
Sets the checked state of the control, and send the press event if desired.
|
void |
setRadioTextGap(int gap)
The gap between the radio and the text when the leftJustify is set to true.
|
void |
setText(java.lang.String text)
Sets the text.
|
void |
sidePaint(Graphics g,
int alpha) |
void |
sideStart() |
void |
sideStop() |
void |
split(int maxWidth)
Splits the text to the given width.
|
_onEvent, addEnabledStateListener, addFocusListener, addFontChangeHandler, addGridListener, addHandler, addHighlightListener, addKeyListener, addListContainerListener, addMouseListener, addMultiTouchListener, addPenListener, addPressListener, addPushNotificationListener, addSizeChangeHandler, addTimer, addTimer, addTimerListener, addValueChangeHandler, addWindowListener, bringToFront, changeHighlighted, contains, drawTranslucentBackground, getAbsoluteRect, getBackColor, getDoEffect, getEffectH, getEffectW, getEffectX, getEffectY, getEventListeners, getFont, getForeColor, getGap, getGraphics, getHeight, getNext, getParent, getParentWindow, getPos, getPressedEvent, getPrev, getRect, getSize, getTextShadowColor, getWidth, getX, getX2, getY, getY2, hadParentScrolled, handleGeographicalFocusChangeKeys, hasFocus, internalSetEnabled, intXYWH, isActionEvent, isChildOf, isDisplayed, isEnabled, isFloating, isInsideOrNear, isObscured, isTopMost, isVisible, isVisibleAndInside, onWindowPaintFinished, post, postEvent, postPressedEvent, releaseScreenShot, removeEnabledStateListener, removeFocusListener, removeGridListener, removeHandler, removeHighlightListener, removeKeyListener, removeListContainerListener, removeMouseListener, removeMultiTouchListener, removePenListener, removePressListener, removePushNotificationListener, removeTimer, removeTimerListener, removeWindowListener, repaint, repaintNow, reposition, reposition, repositionChildren, requestFocus, resetSetPositions, resetStyle, safeRepaintNow, safeUpdateScreen, sendToBack, setBackColor, setBackForeColors, setDoEffect, setEnabled, setFloating, setFocusLess, setFont, setForeColor, setNinePatch, setNinePatch, setRect, setRect, setRect, setRect, setSet, setTextShadowColor, setTranslucent, setVisible, showTip, takeInitialScreenShot, takeScreenShot, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary, willOpenKeyboardpublic boolean autoSplit
public int textColor
public int checkColor
public boolean leftJustify
Attention: You can change the gap between the radio and the text by changing the variable "radioTextGap" by calling setRadioTextGap(int gap)
public Radio(java.lang.String text)
public Radio(java.lang.String text,
RadioGroupController radioGroup)
public RadioGroupController getRadioGroup()
public void setText(java.lang.String text)
setText in interface TextControlpublic java.lang.String getText()
getText in interface TextControlpublic boolean isChecked()
public void setChecked(boolean checked)
public void setChecked(boolean checked,
boolean sendPress)
public int getPreferredWidth()
getPreferredWidth in class Controlpublic int getPreferredHeight()
getPreferredHeight in class Controlpublic void onEvent(Event event)
protected void onColorsChanged(boolean colorsChanged)
ControlonColorsChanged in class Controlprotected void onFontChanged()
ControlonFontChanged in class Controlpublic void onPaint(Graphics g)
public void clear()
public void sideStart()
sideStart in interface MaterialEffect.SideEffectpublic void sideStop()
sideStop in interface MaterialEffect.SideEffectprotected void onBoundsChanged(boolean screenChanged)
ControlonBoundsChanged in class ControlscreenChanged - If the bounds were changed due to a screen change (rotation, collapse)public void split(int maxWidth)
autoSplitpublic void sidePaint(Graphics g, int alpha)
sidePaint in interface MaterialEffect.SideEffectpublic void setRadioTextGap(int gap)
public int getRadioTextGap()