CompoundButton isChecked - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for CompoundButton isChecked method.

This code example shows how to use the following methods:isChecked
        mCheckBox.setChecked(checked);
    } 
 
    @Override 
    public boolean isChecked() { 
        return mCheckBox.isChecked();
    } 
 
    @Override 
    public void toggle() { 
        mCheckBox.toggle();
    } 
} 
8
CodeRank
This code example shows how to use the following methods:isChecked
		assertEquals( null, androidWidgetBuilder.getValue( new View( null ) ) );
		assertFalse( androidWidgetBuilder.setValue( null, null ) );
 
		// CheckBox 
 
		CheckBox checkBox = new CheckBox( null );
		assertTrue( false == (Boolean) androidWidgetBuilder.getValue( checkBox ) );
		androidWidgetBuilder.setValue( true, checkBox );
		assertTrue( checkBox.isChecked() );
		assertTrue( true == (Boolean) androidWidgetBuilder.getValue( checkBox ) );
 
		// TextView 
 
		TextView textView = new TextView( null );
		assertEquals( null, androidWidgetBuilder.getValue( textView ) );
		androidWidgetBuilder.setValue( "foo", textView );
		assertEquals( "foo", textView.getText() );
		assertEquals( "foo", androidWidgetBuilder.getValue( textView ) );
 
		textView.setText( new SpannableStringBuilder( "foo" ) );
7
CodeRank
This code example shows how to use the following methods:isChecked, setChecked
    public FileItemInfoLayout(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    } 
 
    public void toggle() { 
        setChecked(!mCheckbox.isChecked());
    } 
 
    /* (non-Javadoc) 
     * @see android.view.View#onFinishInflate() 
     */ 
    @Override 
    protected void onFinishInflate() { 
        super.onFinishInflate(); 
        mFileNameView = (TextView) findViewById(R.id.misc_filename);
        mFileSizeView = (TextView) findViewById(R.id.misc_filesize);
        mCheckbox = (CheckBox) findViewById(R.id.misc_checkbox);
    } 
 
    public void setFileName(String fileName) {

7
CodeRank
This code example shows how to use the following methods:isChecked
			Button b = (Button) v;
			data.put("text", b.getText().toString());
		} 
		if (v instanceof CheckBox) {
			CheckBox c = (CheckBox) v;
			data.put("checked", c.isChecked());
		} 
		if (v instanceof TextView) {
			TextView t = (TextView) v;
			data.put("text", t.getText().toString());
		} 
		return data;
 
	} 
 
	@SuppressWarnings({ "unchecked", "rawtypes" }) 
	public static Object mapView(Object o) {
		if (o instanceof View) {
			return extractDataFromView((View) o);
		}  
7
CodeRank
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
This code example shows how to use the following methods:isChecked
 
	@Override 
	public void onAccept() { 
		super.onAccept(); 
		AccountManager.getInstance().setPassword(account,
				storePasswordView.isChecked(),
				passwordView.getText().toString());
		finish(); 
	} 
 
	@Override 
	public void onDecline() { 
		AccountManager.getInstance().removePasswordRequest(account);
		finish(); 
	} 
 
	public static Intent createIntent(Context context, String account) {
		return new AccountIntentBuilder(context, PasswordRequest.class)
				.setAccount(account).build();
	} 
7
CodeRank
This code example shows how to use the following methods:isChecked, setOnCheckedChangeListener, setChecked
                mSwitch.setEnabled(true);
        } 
    } 
 
    private void setChecked(boolean isChecked) {
        if (isChecked != mSwitch.isChecked()) {
            // set listener to null, so onCheckedChanged won't be called 
            // if the checked status on Switch isn't changed by user click 
            if (mValidListener) {
                mSwitch.setOnCheckedChangeListener(null);
            } 
            mSwitch.setChecked(isChecked);
            if (mValidListener) {
                mSwitch.setOnCheckedChangeListener(this);
            } 
        } 
    } 
} 
8
CodeRank
This code example shows how to use the following methods:isChecked, setChecked
        /* Stub! */ 
        return; 
    } 
 
    private void setSwitchChecked(boolean checked) {
        if (checked != mSwitch.isChecked()) {
            mStateMachineEvent = true;
            mSwitch.setChecked(checked);
            mStateMachineEvent = false;
        } 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:isChecked, setOnCheckedChangeListener, setChecked, setEnabled
            case BluetoothAdapter.STATE_TURNING_OFF:
                mSwitch.setEnabled(false);
                break; 
            case BluetoothAdapter.STATE_OFF:
                setChecked(false); 
                mSwitch.setEnabled(true);
                break; 
            default: 
                setChecked(false); 
                mSwitch.setEnabled(true);
        } 
    } 
 
    private void setChecked(boolean isChecked) {
        if (isChecked != mSwitch.isChecked()) {
            // set listener to null, so onCheckedChanged won't be called 
            // if the checked status on Switch isn't changed by user click 
            if (mValidListener) {
                mSwitch.setOnCheckedChangeListener(null);
            } 

8
CodeRank
This code example shows how to use the following methods:isChecked, setOnCheckedChangeListener, setChecked
    } 
 
    public void resume() { 
        mPrefs.registerOnSharedPreferenceChangeListener(this);
        setSwitchChecked(mPrefs.getBoolean(mKey, mDefValue));
        mSwitch.setOnCheckedChangeListener(this);
    } 
 
    @Override 
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
        if (key.equals(mKey)) {
            setSwitchChecked(sharedPreferences.getBoolean(mKey, mDefValue));
        } 
    } 
 
    private void setSwitchChecked(boolean checked) {
        if (checked != mSwitch.isChecked()) {
            mStateMachineEvent = true;
            mSwitch.setChecked(checked);
            mStateMachineEvent = false;

8
CodeRank

Related CompoundButton isChecked Questions & Answers:

Other CompoundButton isChecked Examples

1:	public void onCheckboxClicked(View view) {
2:	    // Is the view now checked?
3:	    boolean checked = ((CheckBox) view).isChecked();
4:	    
5:	    // Check which checkbox was clicked

Read More

1:	public void onToggleClicked(View view) {
2:	    // Is the toggle on?
3:	    boolean on = ((ToggleButton) view).isChecked();
4:	    
5:	    if (on) {

Read More

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

isChecked Method Overview
See Code Examples for other Android CompoundButton Methods: