android.widget.CheckBox.setButtonDrawable()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(317)

本文整理了Java中android.widget.CheckBox.setButtonDrawable()方法的一些代码示例,展示了CheckBox.setButtonDrawable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CheckBox.setButtonDrawable()方法的具体详情如下:
包路径:android.widget.CheckBox
类名称:CheckBox
方法名:setButtonDrawable

CheckBox.setButtonDrawable介绍

暂无

代码示例

代码示例来源:origin: aa112901/remusic

@Override
public void setButtonDrawable(@DrawableRes int resId) {
  if (mCompoundButtonHelper != null) {
    mCompoundButtonHelper.setButtonDrawable(resId);
  } else {
    super.setButtonDrawable(resId);
  }
}

代码示例来源:origin: aa112901/remusic

@Nullable
@Override
public void setButtonDrawable(Drawable drawable) {
  super.setButtonDrawable(drawable);
  if (mCompoundButtonHelper != null) {
    mCompoundButtonHelper.setButtonDrawable();
  }
}

代码示例来源:origin: lygttpod/SuperTextView

/**
 * 初始化RightCheckBox
 */
private void initRightCheckBox() {
  if (rightCheckBox == null) {
    rightCheckBox = new CheckBox(mContext);
  }
  rightCheckBoxParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
  rightCheckBoxParams.addRule(ALIGN_PARENT_RIGHT, TRUE);
  rightCheckBoxParams.addRule(RelativeLayout.CENTER_VERTICAL, TRUE);
  rightCheckBoxParams.setMargins(0, 0, rightCheckBoxMarginRight, 0);
  rightCheckBox.setId(R.id.sRightCheckBoxId);
  rightCheckBox.setLayoutParams(rightCheckBoxParams);
  if (rightCheckBoxBg != null) {
    rightCheckBox.setGravity(CENTER_IN_PARENT);
    rightCheckBox.setButtonDrawable(rightCheckBoxBg);
  }
  rightCheckBox.setChecked(isChecked);
  rightCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
      if (checkBoxCheckedChangeListener != null) {
        checkBoxCheckedChangeListener.onCheckedChanged(buttonView, isChecked);
      }
    }
  });
  addView(rightCheckBox);
}

代码示例来源:origin: smuyyh/BookReader

cb.setButtonDrawable(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
if (stateResId == -1) {
  stateResId = R.drawable.book_review_rating_bar_selector;

代码示例来源:origin: flipkart-incubator/proteus

@Override
 public void setDrawable(T view, Drawable drawable) {
  view.setButtonDrawable(drawable);
 }
});

代码示例来源:origin: caozaolin/ReactFloatView

public static void setCheckBoxBackground(CheckBox mChechBox,
    Drawable drawable) {
  mChechBox.setButtonDrawable(drawable);
}

代码示例来源:origin: openmrs/openmrs-contrib-android-client

public void disableCheckBox(PatientViewHolder holder) {
  holder.mAvailableOfflineCheckbox.setChecked(true);
  holder.mAvailableOfflineCheckbox.setClickable(false);
  holder.mAvailableOfflineCheckbox.setButtonDrawable(R.drawable.ic_offline);
}

代码示例来源:origin: stackoverflow.com

public void handleCheckBoxClick(View view) {
  CheckBox chkBox = (CheckBox) findViewById(view.getId());
  if(chkBox.isChecked())
  {
    chkBox.setBackgroundColor(color.blue);
//or
    chkBox.setButtonDrawable(R.drawable.imagechk);
  }
  else
  {
    chkBox.setBackgroundColor(color.red);
//or
 chkBox.setButtonDrawable(R.drawable.imageunchk);
  }
}

代码示例来源:origin: xuerui1993/PhotoPicker

public void setData(MediaPhoto bean, int position) {
    mCheckbox.setButtonDrawable(R.drawable.imagepicker_checkbox_selector);
    mPosition = position;
    mCheckbox.setChecked(bean.isCheck());
    Glide.with(mContext).load(bean.getUrl()).placeholder(R.drawable.content_img).into(mIvPhoto);
  }
}

代码示例来源:origin: YancyYe/GalleryPick

@Override
  public void onClick(View v) {
    if (!galleryConfig.isMultiSelect()) {
      selectPhoto.clear();
      selectPhoto.add(photoInfo.path);
      onCallBack.OnClickPhoto(selectPhoto);
      return;
    }
    if (selectPhoto.contains(photoInfo.path)) {
      selectPhoto.remove(photoInfo.path);
      viewHolder.chkPhotoSelector.setChecked(false);
      viewHolder.chkPhotoSelector.setButtonDrawable(R.mipmap.gallery_pick_select_unchecked);
      viewHolder.vPhotoMask.setVisibility(View.GONE);
    } else {
      if (galleryConfig.getMaxSize() <= selectPhoto.size()) {        // 当选择图片达到上限时, 禁止继续添加
        return;
      }
      selectPhoto.add(photoInfo.path);
      viewHolder.chkPhotoSelector.setChecked(true);
      viewHolder.chkPhotoSelector.setButtonDrawable(R.mipmap.gallery_pick_select_checked);
      viewHolder.vPhotoMask.setVisibility(View.VISIBLE);
    }
    onCallBack.OnClickPhoto(selectPhoto);
  }
});

代码示例来源:origin: stackoverflow.com

final CheckBox checkMark=(CheckBox)view.findViewById(R.id.checkImageMark);
 if(checked){
   checkMark.setVisibility(View.VISIBLE);
   // checkMark.setButtonDrawable(R.drawable.checked24);
   imageView.setOnClickListener(new View.OnClickListener() {
     @Override
     public void onClick(View v) {
       checkMark.setButtonDrawable(!checkMark.isChecked() ? R.drawable.checked24_1 : R.drawable.checked24);
       checkMark.setChecked(!checkMark.isChecked());
     }
   });
 } else {
   checkMark.setVisibility(View.GONE);
   imageView.setOnClickListener(null);
 }

代码示例来源:origin: huangfangyi/FanXin

checkBox.setButtonDrawable(R.drawable.em_checkbox_bg_gray_selector);
}else{
  checkBox.setButtonDrawable(R.drawable.em_checkbox_bg_selector);

代码示例来源:origin: mobileprint/android-print-sdk

if (Build.VERSION.SDK_INT <  Build.VERSION_CODES.LOLLIPOP) {
  int id = Resources.getSystem().getIdentifier("btn_check_holo_light", "drawable", "android");
  checkBox.setButtonDrawable(id);

代码示例来源:origin: garretyoder/app-theme-engine

public static void setTint(@NonNull CheckBox box, @ColorInt int color, boolean useDarker) {
  ColorStateList sl = new ColorStateList(new int[][]{
      new int[]{-android.R.attr.state_enabled},
      new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked},
      new int[]{android.R.attr.state_enabled, android.R.attr.state_checked}
  }, new int[]{
      ContextCompat.getColor(box.getContext(), useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light),
      ContextCompat.getColor(box.getContext(), useDarker ? R.color.ate_control_normal_dark : R.color.ate_control_normal_light),
      color
  });
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    box.setButtonTintList(sl);
  } else {
    Drawable drawable = createTintedDrawable(ContextCompat.getDrawable(box.getContext(), R.drawable.abc_btn_check_material), sl);
    box.setButtonDrawable(drawable);
  }
}

代码示例来源:origin: openmrs/openmrs-contrib-android-client

public void setUpCheckBoxLogic(final PatientViewHolder holder, final Patient patient) {
  if (isLongClicked) {
    holder.mAvailableOfflineCheckbox.setVisibility(View.INVISIBLE);
  } else {
    holder.mAvailableOfflineCheckbox.setChecked(false);
    holder.mAvailableOfflineCheckbox.setVisibility(View.VISIBLE);
    holder.mAvailableOfflineCheckbox.setButtonDrawable(R.drawable.ic_download);
    holder.mAvailableOfflineCheckbox.setText(mContext.getString(R.string.find_patients_row_checkbox_download_label));
    holder.mAvailableOfflineCheckbox.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        if (!isLongClicked && ((CheckBox) v).isChecked()) {
          downloadPatient(patient, true);
          disableCheckBox(holder);
        }
      }
    });
  }
}

代码示例来源:origin: marzika/Snapprefs

/**
   * Opens SnapChat's Resources and gets the pretty checkbox, for reuse & consistent appearance
   *
   * @param c SNAPCHAT's context
   * @return A pretty checkbox (hopefully)
   */
  public static CheckBox getCheckbox(Context c) {
    CheckBox cb = new CheckBox(c);
    try {
      //Setting properties from Snapchat's res/layout/send_to_item.xml checkbox
      cb.setButtonDrawable(c.getResources().getIdentifier("send_to_button_selector", "drawable", "com.snapchat.android"));
      //May need to scale drawable bitmap...
      cb.setScaleX(0.7F);
      cb.setScaleY(0.7F);
    } catch (Exception e) {
      Logger.log("Snapprefs: Error getting Checkbox");
    }
    return cb;
  }
}

代码示例来源:origin: huangfangyi/YiChat

holder.checkBox.setButtonDrawable(R.drawable.bg_checkbox);
} else {
  holder.checkBox.setButtonDrawable(R.drawable.bg_checkbox_blue);

代码示例来源:origin: xuancao/DynamicSkin

public static void setTint(@NonNull CheckBox box, @ColorInt int color, boolean useDarker) {
  ColorStateList sl = new ColorStateList(new int[][]{
      new int[]{-android.R.attr.state_enabled},
      new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked},
      new int[]{android.R.attr.state_enabled, android.R.attr.state_checked}
  }, new int[]{
      ContextCompat.getColor(box.getContext(), useDarker ? R.color.ate_disabled_checkbox_dark : R.color.ate_disabled_checkbox_light),
      Util.resolveColor(box.getContext(), R.attr.colorControlNormal),
      color
  });
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    box.setButtonTintList(sl);
  } else {
    Drawable drawable = tintDrawable(ContextCompat.getDrawable(box.getContext(), R.drawable.abc_btn_check_material), sl);
    box.setButtonDrawable(drawable);
  }
}

代码示例来源:origin: WomenWhoCode/WomenWhoCode

cb.setButtonDrawable(ContextCompat.getDrawable(getContext(), R.drawable.check_box_selector));

代码示例来源:origin: h4h13/RetroMusicPlayer

public static void setTint(@NonNull CheckBox box, @ColorInt int color, boolean useDarker) {
  ColorStateList sl = new ColorStateList(new int[][]{
      new int[]{-android.R.attr.state_enabled},
      new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked},
      new int[]{android.R.attr.state_enabled, android.R.attr.state_checked}
  }, new int[]{
      ContextCompat.getColor(box.getContext(), useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light),
      ContextCompat.getColor(box.getContext(), useDarker ? R.color.ate_control_normal_dark : R.color.ate_control_normal_light),
      color
  });
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    box.setButtonTintList(sl);
  } else {
    Drawable drawable = createTintedDrawable(ContextCompat.getDrawable(box.getContext(), R.drawable.abc_btn_check_material), sl);
    box.setButtonDrawable(drawable);
  }
}

相关文章