Android: Change the color of RadioButtons and checkboxes programmatically

前端 未结 6 1222
轮回少年
轮回少年 2020-12-15 08:11

I created RadioButton and CheckBox in LinearLayout programatically. But, now I want to change radio button\'s color and check boxes\'s

6条回答
  •  生来不讨喜
    2020-12-15 08:48

       RadioButton rb=(RadioButton) findViewById(R.id.radioButton1);
        rb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
    
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                // TODO Auto-generated method stub
                rb.setButtonDrawable(R.drawable.image);
                rb.setHighlightColor(Color.parseColor("#0c83bd"));
    
    
            }
        });
      }
    

提交回复
热议问题