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

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

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

CheckBox.getContext介绍

暂无

代码示例

代码示例来源: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: commonsguy/cw-androidarch

RosterRowHolder(TodoRowBinding binding, RosterListAdapter adapter) {
 super(binding.getRoot());
 this.binding=binding;
 this.adapter=adapter;
 expandCheckbox(binding.checkbox,
  binding.checkbox.getContext().getResources().getDimensionPixelSize(
   R.dimen.expanded_cb_size));
}

代码示例来源: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: 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);
  }
}

代码示例来源:origin: labexp/osmtracker-android

String iso = getIso(layoutsFileNames.get(checkboxHeld.getText()));
String info[]= {layoutName, iso};
final ProgressDialog dialog = new ProgressDialog(checkboxHeld.getContext());
dialog.setMessage(getResources().getString(R.string.buttons_presets_updating_layout));
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);

代码示例来源:origin: HelloChenJinJun/TestChat

@Override
    public void onClick(View v) {
        LogUtil.e("这里1122呢");
        int size = CommonImageLoader.getInstance().getMaxSelectedCount();
        int selectedCount = CommonImageLoader.getInstance().getSelectedImages().size();
        CheckBox checkBox = (CheckBox) v;
        if (checkBox.isChecked()) {
            LogUtil.e("已选择");
            if (selectedCount >= size) {
                Toast.makeText(checkBox.getContext(), "最多只能选择" + size + "张图片", Toast.LENGTH_SHORT).show();
                checkBox.setChecked(false);
                return;
            } else {
                holder.setVisible(R.id.view_select_picture_list_item_mask, true);
                CommonImageLoader.getInstance().getSelectedImages().add(CommonImageLoader.getInstance().getCurrentImageFolder().getAllImages().get((holder.getAdapterPosition() - 1)));
            }
        } else {
            LogUtil.e("未选择");
            holder.setVisible(R.id.view_select_picture_list_item_mask, false);
            CommonImageLoader.getInstance().getSelectedImages().remove(CommonImageLoader.getInstance().getCurrentImageFolder().getAllImages().get((holder.getAdapterPosition() - 1)));
        }
        if (mOnItemCheckClickListener != null) {
            mOnItemCheckClickListener.onItemCheck(checkBox, holder.getAdapterPosition());
        }
    }
});

相关文章