Android RadioButton - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android RadioButton class.

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
Stop searching for code, let great code find you!  Add Codota to your java IDE
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
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setClickable, setChecked, setOnCheckedChangeListener
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
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
Stop searching for code, let great code find you!  Add Codota to your java IDE
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
Stop searching for code, let great code find you!  Add Codota to your java IDE

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: