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());
 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
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(); 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setClickable, setChecked, setOnCheckedChangeListener
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
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);
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
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(); 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
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(); 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getId
	 * @return 
	 */ 
	public int getId() 
	{ 
		RadioButton radioButton = (RadioButton) getView( );
		return radioButton.getId();
	} 
 
	public void setId(int id)
	{ 
		RadioButton radioButton = (RadioButton) getView( );
		radioButton.setId(id);
	} 
 
	@Override 
	public boolean setProperty(String property, String value)
			throws PropertyConversionException, InvalidPropertyValueException 
	{ 
		if( super.setProperty(property, value) )
		{ 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:isChecked, getText
    	findViewById(R.id.btnContinue).setOnClickListener(new Button.OnClickListener() {
    		public void onClick(View v) {
    			Intent resultIntent = new Intent();
    			resultIntent.putExtra("dlr.stressrecognition.Name", nameText.getText().toString());
    			resultIntent.putExtra("dlr.stressrecognition.Age", ageText.getText().toString());
                if(radioMale.isChecked()) {
                	resultIntent.putExtra("dlr.stressrecognition.Gender", radioMale.getText());
                } else { 
                	resultIntent.putExtra("dlr.stressrecognition.Gender", radioFemale.getText());
                } 
                // Set result and finish this Activity 
                setResult(Activity.RESULT_OK, resultIntent);
                finish();
    		} 
    	}); 
    	   	 
	} 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setId, setTag, setChecked, setText
	public Object getValue() {
		return group.findViewById(group.getCheckedRadioButtonId()).getTag();
	} 
	 
	public void addRadio(Object target, String text, boolean isSelected) {
		RadioButton rb = new RadioButton(getContext());
		rb.setText(text);
		rb.setTag(target);
		rb.setId(id++);
		rb.setChecked(isSelected);
		group.addView(rb);
	} 
 
	@Override 
	protected View createEditView() {
		group = new RadioGroup(getContext());
		return group;
	} 
 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setOnClickListener, setVisibility, setChecked
            } 
            if (separator != null) {
                separator.setVisibility(View.VISIBLE);
            } 
            if (rb != null) {
                rb.setVisibility(View.GONE);
            } 
        } else { 
            if (separator != null) {
                separator.setVisibility(View.GONE);
            } 
             
            BhoOptions option = mData.get(position);
            if (tv != null) {
                tv.setVisibility(View.VISIBLE);
                tv.setText(option.getLabel());
            } 
             
            if (rb != null) {
                rb.setVisibility(View.VISIBLE);

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

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: