CompoundButton 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 CompoundButton setChecked method.

This code example shows how to use the following methods:setId, setLayoutParams, setChecked, setOnCheckedChangeListener
				RelativeLayout.LayoutParams.WRAP_CONTENT,
				RelativeLayout.LayoutParams.WRAP_CONTENT);
		checkboxparams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
		checkboxparams.addRule(RelativeLayout.CENTER_VERTICAL);
 
		checkbox = new CheckBox(getContext());
		checkbox.setLayoutParams(checkboxparams);
		checkbox.setOnCheckedChangeListener(this);
		checkbox.setId(CHECKBOX_ID);
		 
		 
 
		layout.addView(title);
		layout.addView(description);
		layout.addView(checkbox);
		layout.setId(android.R.id.widget_frame);
 
		checkService(); 
		 
		return layout;

7
CodeRank
This code example shows how to use the following methods:setChecked
                insertCheckBox(); 
            } 
            compoundButton = mCheckBox;
        } 
 
        compoundButton.setChecked(checked);
    } 
 
    public void setShortcut(boolean showShortcut, char shortcutKey) {
        final int newVisibility = (showShortcut && mItemData.shouldShowShortcut())
                ? VISIBLE : GONE;
 
        if (newVisibility == VISIBLE) {
            mShortcutView.setText(mItemData.getShortcutLabel());
        } 
 
        if (mShortcutView.getVisibility() != newVisibility) {
            mShortcutView.setVisibility(newVisibility);
        } 
    } 
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:setChecked
        mCheckBox = (CheckBox) findViewById(R.id.check);
    } 
 
    @Override 
    public void setChecked(boolean checked) {
        mCheckBox.setChecked(checked);
    } 
 
    @Override 
    public boolean isChecked() { 
        return mCheckBox.isChecked();
    } 
 
    @Override 
    public void toggle() { 
        mCheckBox.toggle();
    } 
} 
7
CodeRank
This code example shows how to use the following methods:setLayoutParams, setOnClickListener, setChecked, setGravity, setPadding
 
        public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
            AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
                    ViewGroup.LayoutParams.FILL_PARENT, 64);
 
            CheckBox checkBox = new CheckBox(Plugins_View.this);
            checkBox.setLayoutParams(lp);
            // Center the text vertically 
            checkBox.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER);
            // Set the text starting position 
            checkBox.setOnClickListener(new OnClickListener(){
            	public void onClick(View v){
                    if (((CheckBox) v).isChecked()) {
                    	SharedPreferences settings = getSharedPreferences("Munin_Node", 0);
                        SharedPreferences.Editor editor = settings.edit();
                        editor.putBoolean(((CheckBox) v).getText().toString(), true);
                        editor.commit();
                    } else { 
                    	SharedPreferences settings = getSharedPreferences("Munin_Node", 0);
                        SharedPreferences.Editor editor = settings.edit();

7
CodeRank
This code example shows how to use the following methods:setTag, setChecked, setOnCheckedChangeListener
    } 
 
    private void initItemCheckbox(int position, ViewGroup view) {
        CheckBox checkBox = (CheckBox) view.findViewById(android.R.id.checkbox);
        boolean selected = isSelected(position);
        checkBox.setTag(position);
        checkBox.setChecked(selected);
        checkBox.setOnCheckedChangeListener(this);
    } 
 
    @SuppressWarnings("deprecation") 
    private void updateItemBackground(int position, View v) {
        long handle = positionToSelectionHandle(position);
        boolean selected = isSelected(handle);
        Drawable bg = selected ? selectedItemBackground : unselectedItemBackground;
        v.setBackgroundDrawable(bg);
    } 
     
    @Override 
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
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:setClickable, setChecked, setOnCheckedChangeListener
8
CodeRank
This code example shows how to use the following methods:setChecked
                insertCheckBox(); 
            } 
            compoundButton = mCheckBox;
        } 
         
        compoundButton.setChecked(checked);
    } 
 
    public void setShortcut(boolean showShortcut, char shortcutKey) {
        final int newVisibility = (showShortcut && mItemData.shouldShowShortcut())
                ? VISIBLE : GONE;
 
        if (newVisibility == VISIBLE) {
            mShortcutView.setText(mItemData.getShortcutLabel());
        } 
 
        if (mShortcutView.getVisibility() != newVisibility) {
            mShortcutView.setVisibility(newVisibility);
        } 
    } 
6
CodeRank
This code example shows how to use the following methods:setChecked, setOnCheckedChangeListener

Related CompoundButton setChecked Questions & Answers:

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