Switch setChecked - top ranked examples from Open Source projects

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

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:setChecked, setEnabled
    } 
 
    @Override 
    public void onCheckedChanged(CompoundButton buttonView, boolean desiredState) {
        boolean success = false;
        mActionBarSwitch.setEnabled(false);
        if (desiredState) {
            success = mNfcAdapter.enableNdefPush();
        } else { 
            success = mNfcAdapter.disableNdefPush();
        } 
        if (success) {
            mActionBarSwitch.setChecked(desiredState);
        } 
        mActionBarSwitch.setEnabled(true);
    } 
} 
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
This code example shows how to use the following methods:setChecked, setEnabled
    } 
 
    @Override 
    public void onCheckedChanged(CompoundButton buttonView, boolean desiredState) {
        boolean success = false;
        mActionBarSwitch.setEnabled(false);
        if (desiredState) {
            success = mNfcAdapter.enableNdefPush();
        } else { 
            success = mNfcAdapter.disableNdefPush();
        } 
        if (success) {
            mActionBarSwitch.setChecked(desiredState);
        } 
        mActionBarSwitch.setEnabled(true);
    } 
} 
7
CodeRank
This code example shows how to use the following methods:setChecked
            Log.e(TAG, "Invalid preference value.");
            mPreference.print();
            throw new IllegalArgumentException();
        } else if (index == 0) {
            // default choice: time lapse off 
            mTimeLapseSwitch.setChecked(false);
            setTimeSelectionEnabled(false); 
        } else { 
            mTimeLapseSwitch.setChecked(true);
            setTimeSelectionEnabled(true); 
            int durationCount = mNumberSpinner.getMaxValue() + 1;
            int unit = (index - 1) / durationCount;
            int number = (index - 1) % durationCount;
            mUnitSpinner.setValue(unit);
            mNumberSpinner.setValue(number);
        } 
    } 
 
    @Override 
    public void setVisibility(int visibility) {
5
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;
        } 
    } 
} 
6
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;
        } 
    } 
} 
5
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;
        } 
    } 
} 
6
CodeRank

Related Switch setChecked Questions & Answers:

setChecked Method Overview
Changes the checked state of this button.
See Code Examples for other Android Switch Methods: