Methods Summary |
---|
public void | addView(android.view.View child, int index, ViewGroup.LayoutParams params)
if (child instanceof RadioButton) {
final RadioButton button = (RadioButton) child;
if (button.isChecked()) {
mProtectFromCheckedChange = true;
if (mCheckedId != -1) {
setCheckedStateForView(mCheckedId, false);
}
mProtectFromCheckedChange = false;
setCheckedId(button.getId());
}
}
super.addView(child, index, params);
|
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 {@link #clearCheck()}.
// don't even bother
if (id != -1 && (id == mCheckedId)) {
return;
}
if (mCheckedId != -1) {
setCheckedStateForView(mCheckedId, false);
}
if (id != -1) {
setCheckedStateForView(id, true);
}
setCheckedId(id);
|
protected boolean | checkLayoutParams(ViewGroup.LayoutParams p){@inheritDoc}
return p instanceof RadioGroup.LayoutParams;
|
public void | clearCheck()Clears the selection. When the selection is cleared, no radio button
in this group is selected and {@link #getCheckedRadioButtonId()} returns
null.
check(-1);
|
protected LinearLayout.LayoutParams | generateDefaultLayoutParams()
return new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
public android.widget.RadioGroup$LayoutParams | generateLayoutParams(android.util.AttributeSet attrs){@inheritDoc}
return new RadioGroup.LayoutParams(getContext(), attrs);
|
public int | getCheckedRadioButtonId()Returns the identifier of the selected radio button in this group.
Upon empty selection, the returned value is -1.
return mCheckedId;
|
private void | init()
mChildOnCheckedChangeListener = new CheckedStateTracker();
mPassThroughListener = new PassThroughHierarchyChangeListener();
super.setOnHierarchyChangeListener(mPassThroughListener);
|
protected void | onFinishInflate(){@inheritDoc}
super.onFinishInflate();
// checks the appropriate radio button as requested in the XML file
if (mCheckedId != -1) {
mProtectFromCheckedChange = true;
setCheckedStateForView(mCheckedId, true);
mProtectFromCheckedChange = false;
setCheckedId(mCheckedId);
}
|
private void | setCheckedId(int id)
mCheckedId = id;
if (mOnCheckedChangeListener != null) {
mOnCheckedChangeListener.onCheckedChanged(this, mCheckedId);
}
|
private void | setCheckedStateForView(int viewId, boolean checked)
View checkedView = findViewById(viewId);
if (checkedView != null && checkedView instanceof RadioButton) {
((RadioButton) checkedView).setChecked(checked);
}
|
public void | setOnCheckedChangeListener(android.widget.RadioGroup$OnCheckedChangeListener listener)Register a callback to be invoked when the checked radio button
changes in this group.
mOnCheckedChangeListener = listener;
|
public void | setOnHierarchyChangeListener(OnHierarchyChangeListener listener){@inheritDoc}
// the user listener is delegated to our pass-through listener
mPassThroughListener.mOnHierarchyChangeListener = listener;
|