Build 1.0_r1(from source)

android.widget
Class RadioGroup

java.lang.Object
  extended by android.view.View
      extended by android.view.ViewGroup
          extended by android.widget.LinearLayout
              extended by android.widget.RadioGroup
All Implemented Interfaces:
Drawable.Callback, KeyEvent.Callback, ViewManager, ViewParent

public class RadioGroup
extends LinearLayout

This class is used to create a multiple-exclusion scope for a set of radio buttons. Checking one radio button that belongs to a radio group unchecks any previously checked radio button within the same group.

Intially, all of the radio buttons are unchecked. While it is not possible to uncheck a particular radio button, the radio group can be cleared to remove the checked state.

The selection is identified by the unique id of the radio button as defined in the XML layout file.

XML Attributes

See RadioGroup Attributes, LinearLayout Attributes, ViewGroup Attributes, View Attributes

Also see LinearLayout.LayoutParams for layout attributes.

See Also:
RadioButton

Nested Class Summary
static class RadioGroup.LayoutParams
          This set of layout parameters defaults the width and the height of the children to ViewGroup.LayoutParams.WRAP_CONTENT when they are not specified in the XML file.
static interface RadioGroup.OnCheckedChangeListener
          Interface definition for a callback to be invoked when the checked radio button changed in this group.
 
Nested classes/interfaces inherited from class android.view.ViewGroup
ViewGroup.MarginLayoutParams, ViewGroup.OnHierarchyChangeListener
 
Nested classes/interfaces inherited from class android.view.View
View.BaseSavedState, View.MeasureSpec, View.OnClickListener, View.OnCreateContextMenuListener, View.OnFocusChangeListener, View.OnKeyListener, View.OnLongClickListener, View.OnTouchListener
 
Field Summary
 
Fields inherited from class android.widget.LinearLayout
HORIZONTAL, VERTICAL
 
Fields inherited from class android.view.ViewGroup
CLIP_TO_PADDING_MASK, FLAG_SUPPORT_STATIC_TRANSFORMATIONS, FLAG_USE_CHILD_DRAWING_ORDER, FOCUS_AFTER_DESCENDANTS, FOCUS_BEFORE_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS, mDisappearingChildren, mGroupFlags, mOnHierarchyChangeListener, mPersistentDrawingCache, PERSISTENT_ALL_CACHES, PERSISTENT_ANIMATION_CACHE, PERSISTENT_NO_CACHE, PERSISTENT_SCROLLING_CACHE
 
Fields inherited from class android.view.View
DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FIRST_STATE_SET, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, INVISIBLE, KEEP_SCREEN_ON, LAST_STATE_SET, mBottom, mContext, mCurrentAnimation, MIDDLE_STATE_SET, mLayoutParams, mLeft, mLocation, mMeasuredHeight, mMeasuredWidth, mOnClickListener, mOnCreateContextMenuListener, mOnFocusChangeListener, mOnLongClickListener, mPaddingBottom, mPaddingLeft, mPaddingRight, mPaddingTop, mParent, mRight, mScrollX, mScrollY, mTag, mTop, NO_ID, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FIRST_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_LAST_STATE_SET, PRESSED_MIDDLE_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_SINGLE_STATE_SET, PRESSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SINGLE_STATE_SET, SOUND_EFFECTS_ENABLED, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET
 
Constructor Summary
RadioGroup(Context context)
          
RadioGroup(Context context, AttributeSet attrs)
          
 
Method Summary
 void check(int id)
          Sets the selection to the radio button whose identifier is passed in parameter.
protected  boolean checkLayoutParams(ViewGroup.LayoutParams p)
          
 void clearCheck()
          Clears the selection.
protected  LinearLayout.LayoutParams generateDefaultLayoutParams()
          Returns a set of layout parameters with a width of ViewGroup.LayoutParams.FILL_PARENT and a height of ViewGroup.LayoutParams.WRAP_CONTENT when the layout's orientation is LinearLayout.VERTICAL.
 RadioGroup.LayoutParams generateLayoutParams(AttributeSet attrs)
          Returns a new set of layout parameters based on the supplied attributes set.
 int getCheckedRadioButtonId()
          Returns the identifier of the selected radio button in this group.
protected  void onFinishInflate()
          Finalize inflating a view from XML.
 void setOnCheckedChangeListener(RadioGroup.OnCheckedChangeListener listener)
          Register a callback to be invoked when the checked radio button changes in this group.
 void setOnHierarchyChangeListener(ViewGroup.OnHierarchyChangeListener listener)
          Register a callback to be invoked when a child is added to or removed from this view.
 
Methods inherited from class android.widget.LinearLayout
generateLayoutParams, getBaseline, getBaselineAlignedChildIndex, getChildrenSkipCount, getLocationOffset, getNextLocationOffset, getOrientation, getVirtualChildAt, getVirtualChildCount, getWeightSum, isBaselineAligned, layoutHorizontal, layoutVertical, measureChildBeforeLayout, measureHorizontal, measureNullChild, measureVertical, onLayout, onMeasure, setBaselineAligned, setBaselineAlignedChildIndex, setGravity, setHorizontalGravity, setOrientation, setVerticalGravity, setWeightSum
 
Methods inherited from class android.view.ViewGroup
addFocusables, addStatesFromChildren, addTouchables, addView, addView, addView, addView, addView, addViewInLayout, addViewInLayout, attachLayoutAnimationParameters, attachViewToParent, bringChildToFront, canAnimate, childDrawableStateChanged, cleanupLayoutState, clearChildFocus, clearDisappearingChildren, clearFocus, debug, detachAllViewsFromParent, detachViewFromParent, detachViewFromParent, detachViewsFromParent, dispatchDraw, dispatchFreezeSelfOnly, dispatchKeyEvent, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetPressed, dispatchSetSelected, dispatchThawSelfOnly, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchWindowFocusChanged, dispatchWindowVisibilityChanged, drawableStateChanged, drawChild, findFocus, findViewTraversal, findViewWithTagTraversal, fitSystemWindows, focusableViewAvailable, focusSearch, gatherTransparentRegion, getChildAt, getChildCount, getChildDrawingOrder, getChildMeasureSpec, getChildStaticTransformation, getChildVisibleRect, getDescendantFocusability, getFocusedChild, getLayoutAnimation, getLayoutAnimationListener, getPersistentDrawingCache, hasFocus, hasFocusable, indexOfChild, invalidateChild, invalidateChildInParent, isAlwaysDrawnWithCacheEnabled, isAnimationCacheEnabled, isChildrenDrawnWithCacheEnabled, measureChild, measureChildren, measureChildWithMargins, offsetChildrenTopAndBottom, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onAnimationEnd, onAnimationStart, onCreateDrawableState, onInterceptTouchEvent, onRequestFocusInDescendants, recomputeViewAttributes, removeAllViews, removeAllViewsInLayout, removeDetachedView, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, requestChildFocus, requestChildRectangleOnScreen, requestDisallowInterceptTouchEvent, requestFocus, requestTransparentRegion, scheduleLayoutAnimation, setAddStatesFromChildren, setAlwaysDrawnWithCacheEnabled, setAnimationCacheEnabled, setChildrenDrawingCacheEnabled, setChildrenDrawnWithCacheEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutAnimation, setLayoutAnimationListener, setPadding, setPersistentDrawingCache, showContextMenuForChild, startLayoutAnimation, updateViewLayout
 
Methods inherited from class android.view.View
applyDrawableToTransparentRegion, bringToFront, buildDrawingCache, cancelLongPress, clearAnimation, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeScroll, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createContextMenu, debug, debugIndent, destroyDrawingCache, dispatchKeyShortcutEvent, draw, finalize, findViewById, findViewWithTag, focusSearch, forceLayout, getAnimation, getApplicationWindowToken, getBackground, getBottom, getBottomFadingEdgeStrength, getContext, getContextMenuInfo, getDefaultSize, getDrawableState, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getFocusables, getFocusedRect, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getId, getKeepScreenOn, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMeasuredHeight, getMeasuredWidth, getNextFocusDownId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getParent, getResources, getRight, getRightFadingEdgeStrength, getRootView, getScrollBarStyle, getScrollX, getScrollY, getSolidColor, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getTag, getTop, getTopFadingEdgeStrength, getTouchables, getTouchDelegate, getVerticalFadingEdgeLength, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowToken, getWindowVisibility, hasWindowFocus, inflate, initializeFadingEdge, initializeScrollbars, invalidate, invalidate, invalidate, invalidateDrawable, isClickable, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isInTouchMode, isLayoutRequested, isLongClickable, isPressed, isRootNamespace, isSaveEnabled, isSelected, isShown, isSoundEffectsEnabled, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, layout, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onAttachedToWindow, onCreateContextMenu, onDetachedFromWindow, onDraw, onFocusChanged, onKeyDown, onKeyMultiple, onKeyShortcut, onKeyUp, onRestoreInstanceState, onSaveInstanceState, onScrollChanged, onSetAlpha, onSizeChanged, onTouchEvent, onTrackballEvent, onWindowFocusChanged, onWindowVisibilityChanged, performClick, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, refreshDrawableState, removeCallbacks, requestFocus, requestFocus, requestFocusFromTouch, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, resolveSize, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, setAnimation, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setClickable, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setEnabled, setFadingEdgeLength, setFocusable, setFocusableInTouchMode, setFrame, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setId, setIsRootNamespace, setKeepScreenOn, setLayoutParams, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNextFocusDownId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnCreateContextMenuListener, setOnFocusChangeListener, setOnKeyListener, setOnLongClickListener, setOnTouchListener, setPressed, setSaveEnabled, setScrollBarStyle, setSelected, setSoundEffectsEnabled, setTag, setTouchDelegate, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVisibility, setWillNotCacheDrawing, setWillNotDraw, showContextMenu, startAnimation, unscheduleDrawable, unscheduleDrawable, verifyDrawable, willNotCacheDrawing, willNotDraw
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface android.view.ViewParent
createContextMenu, getParent, isLayoutRequested, requestLayout
 

Constructor Detail

RadioGroup

public RadioGroup(Context context)


RadioGroup

public RadioGroup(Context context,
                  AttributeSet attrs)

Method Detail

setOnHierarchyChangeListener

public void setOnHierarchyChangeListener(ViewGroup.OnHierarchyChangeListener listener)
Register a callback to be invoked when a child is added to or removed from this view.

Overrides:
setOnHierarchyChangeListener in class ViewGroup
Parameters:
listener - the callback to invoke on hierarchy change

onFinishInflate

protected void onFinishInflate()
Finalize inflating a view from XML. This is called as the last phase of inflation, after all child views have been added.

Even if the subclass overrides onFinishInflate, they should always be sure to call the super method, so that we get called.

Overrides:
onFinishInflate in class View

check

public void check(int id)

Sets the selection to the radio button whose identifier is passed in parameter. Using -1 as the selection identifier clears the selection; such an operation is equivalent to invoking clearCheck().

Parameters:
id - the unique id of the radio button to select in this group
See Also:
getCheckedRadioButtonId(), clearCheck()

getCheckedRadioButtonId

public int getCheckedRadioButtonId()

Returns the identifier of the selected radio button in this group. Upon empty selection, the returned value is -1.

Returns:
the unique id of the selected radio button in this group
See Also:
check(int), clearCheck()

clearCheck

public void clearCheck()

Clears the selection. When the selection is cleared, no radio button in this group is selected and getCheckedRadioButtonId() returns null.

See Also:
check(int), getCheckedRadioButtonId()

setOnCheckedChangeListener

public void setOnCheckedChangeListener(RadioGroup.OnCheckedChangeListener listener)

Register a callback to be invoked when the checked radio button changes in this group.

Parameters:
listener - the callback to call on checked state change

generateLayoutParams

public RadioGroup.LayoutParams generateLayoutParams(AttributeSet attrs)
Returns a new set of layout parameters based on the supplied attributes set.

Overrides:
generateLayoutParams in class LinearLayout
Parameters:
attrs - the attributes to build the layout parameters from
Returns:
an instance of ViewGroup.LayoutParams or one of its descendants

checkLayoutParams

protected boolean checkLayoutParams(ViewGroup.LayoutParams p)

Overrides:
checkLayoutParams in class LinearLayout

generateDefaultLayoutParams

protected LinearLayout.LayoutParams generateDefaultLayoutParams()
Description copied from class: LinearLayout
Returns a set of layout parameters with a width of ViewGroup.LayoutParams.FILL_PARENT and a height of ViewGroup.LayoutParams.WRAP_CONTENT when the layout's orientation is LinearLayout.VERTICAL. When the orientation is LinearLayout.HORIZONTAL, the width is set to ViewGroup.LayoutParams.WRAP_CONTENT and the height to ViewGroup.LayoutParams.WRAP_CONTENT.

Overrides:
generateDefaultLayoutParams in class LinearLayout
Returns:
a set of default layout parameters or null

Build 1.0_r1(from source)

Please submit a feedback, bug or feature