Best code examples for Android RadioButton class (android.widget.RadioButton)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android RadioButton class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android RadioButton examples from Open Source projects
This code example shows how to use the following methods: isChecked, setChecked
 
@RunWith(WithTestDefaultsRunner.class) 
public class RadioButtonTest { 
    @Test 
    public void canBeExplicitlyChecked() throws Exception { 
        RadioButton radioButton = new RadioButton(null);
        assertFalse(radioButton.isChecked());
 
        radioButton.setChecked(true);
        assertTrue(radioButton.isChecked());
 
        radioButton.setChecked(false);
        assertFalse(radioButton.isChecked());
    } 
 
    @Test 
    public void canBeToggledBetweenCheckedState() throws Exception { 
        RadioButton radioButton = new RadioButton(null);
        assertFalse(radioButton.isChecked());
 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setVisibility
            if (otherCompoundButton.getVisibility() != GONE) {
                otherCompoundButton.setVisibility(GONE);
            } 
        } else { 
            mCheckBox.setVisibility(GONE);
            mRadioButton.setVisibility(GONE);
        } 
    } 
 
    public void setChecked(boolean checked) {
        CompoundButton compoundButton;
 
        if (mItemData.isExclusiveCheckable()) {
            if (mRadioButton == null) {
                insertRadioButton(); 
            } 
            compoundButton = mRadioButton;
        } else { 
            if (mCheckBox == null) {
                insertCheckBox(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setClickable, setChecked, setOnCheckedChangeListener
8
CodeRank
This code example shows how to use the following methods: setClickable, setFocusable, setChecked
				LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
		params.weight = 1;
		params.gravity = Gravity.CENTER_VERTICAL;
		addView(mText, params);
		//add radio button 
		mRadioBtn = new RadioButton(context);
		mRadioBtn.setChecked(textSelected.getSelected());
		mRadioBtn.setFocusable(false);
		mRadioBtn.setClickable(false);
		addView(mRadioBtn, new LinearLayout.LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
	} 
 
	public void setText(String words) {
		mText.setText(words);
	} 
	 
	public void setSelected(boolean selected) {
		mRadioBtn.setChecked(selected);
		mTextSelected.setSelected(selected);
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setVisibility
            if (otherCompoundButton != null && otherCompoundButton.getVisibility() != GONE) {
                otherCompoundButton.setVisibility(GONE);
            } 
        } else { 
            if (mCheckBox != null) mCheckBox.setVisibility(GONE);
            if (mRadioButton != null) mRadioButton.setVisibility(GONE);
        } 
    } 
     
    public void setChecked(boolean checked) {
        CompoundButton compoundButton;
         
        if (mItemData.isExclusiveCheckable()) {
            if (mRadioButton == null) {
                insertRadioButton(); 
            } 
            compoundButton = mRadioButton;
        } else { 
            if (mCheckBox == null) {
                insertCheckBox(); 
Full Snippet Info
6
CodeRank
Related Android RadioButton Questions & Answers:
Other Android RadioButton Examples
1:	public void onRadioButtonClicked(View view) {
2:	    // Is the button now checked?
3:	    boolean checked = ((RadioButton) view).isChecked();
4:	    
5:	    // Check which radio button was clicked

Read More

See Code Examples for Android RadioButton Methods: