本文整理汇总了Java中android.widget.CheckBox.setButtonDrawable方法的典型用法代码示例。如果您正苦于以下问题:Java CheckBox.setButtonDrawable方法的具体用法?Java CheckBox.setButtonDrawable怎么用?Java CheckBox.setButtonDrawable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.CheckBox
的用法示例。
在下文中一共展示了CheckBox.setButtonDrawable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setTint
import android.widget.CheckBox; //导入方法依赖的package包/类
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);
}
}
示例2: initView
import android.widget.CheckBox; //导入方法依赖的package包/类
private void initView() {
removeAllViews();
for (int i = 0; i < countNum; i++) {
CheckBox cb = new CheckBox(getContext());
LayoutParams layoutParams;
if (widthAndHeight == 0) {
layoutParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
} else {
layoutParams = new LayoutParams((int) widthAndHeight, (int) widthAndHeight);
}
if (differentSize && countNum % 2 != 0) {
Log.e("xxx", layoutParams.width + "");
int index = i;
if (index > countNum / 2) {
index = countNum - 1 - index;
}
float scale = (index + 1) / (float) (countNum / 2 + 1);
layoutParams.width = (int) (layoutParams.width * scale);
layoutParams.height = layoutParams.width;
}
layoutParams.gravity = Gravity.CENTER_VERTICAL;
if (i != 0 && i != countNum - 1) {
layoutParams.leftMargin = (int) dividerWidth;
layoutParams.rightMargin = (int) dividerWidth;
} else if (i == 0) {
layoutParams.rightMargin = (int) dividerWidth;
} else if (i == countNum - 1) {
layoutParams.leftMargin = (int) dividerWidth;
}
addView(cb, layoutParams);
cb.setButtonDrawable(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
if (stateResId == -1) {
stateResId = R.drawable.book_review_rating_bar_selector;
}
cb.setBackgroundResource(stateResId);
if (i + 1 <= countSelected) {
cb.setChecked(true);
}
cb.setEnabled(canEdit);
cb.setOnClickListener(new MyClickListener(i));
}
}
示例3: beautyCheckButton
import android.widget.CheckBox; //导入方法依赖的package包/类
protected void beautyCheckButton(CheckBox mCheckBox, OnCheckedChangeListener mOnCheckedChangeListener) {
mCheckBox.setButtonDrawable(this.crMgmt.getCheckStatusDrawable("uac_showpwd_normal", "uac_showpwd_press", false));
mCheckBox.setOnCheckedChangeListener(mOnCheckedChangeListener);
}
示例4: setCheckBoxBackground
import android.widget.CheckBox; //导入方法依赖的package包/类
public static void setCheckBoxBackground(CheckBox mChechBox, Drawable drawable) {
mChechBox.setButtonDrawable(drawable);
}
示例5: getView
import android.widget.CheckBox; //导入方法依赖的package包/类
/**
* @brief Returns the view clicked in the list
* @param position
* @param convertView
* @param parent
* @return view
* @details Returns the view clicked in the list, put the connection name, the ip, and the
* icon star
*/
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView == null) {
LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
vi = inflater.inflate(R.layout.element_user, null);
}
final Connection user = getList().get(position);
final CheckBox iconFav = (CheckBox)vi.findViewById(R.id.checkFav);
iconFav.setTag(user);
iconFav.setOnCheckedChangeListener(
new CheckBox.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if (isChecked){
iconFav.setButtonDrawable(R.drawable.star_ful);
user.setFav(true);
}
else {
iconFav.setButtonDrawable(R.drawable.star_emp);
user.setFav(false);
}
listFragment.refreshFavorites(user);
}
});
//para mantener el estado cuando rota
if (user.isFav()){
iconFav.setButtonDrawable(R.drawable.star_ful);
iconFav.setChecked(true);
}
else{
iconFav.setButtonDrawable(R.drawable.star_emp);
}
TextView name = (TextView) vi.findViewById(R.id.nameConnection);
name.setText(user.getName());
TextView ip_view = (TextView) vi.findViewById(R.id.descIP);
ip_view.setText(user.getIP());
CheckBox iconConnect = (CheckBox)vi.findViewById(R.id.checkConnect);
iconConnect.setTag(user);
return vi;
}