I have implemented checkbox programtically via for loop, how to change them to black color since other textviews are in black color its lucking odd, they are not in the xml ... there is one linear layout where these are getting added.
for (int i = 0; i < list_sted.size(); i++) {
CheckBox cb = new CheckBox(getApplicationContext());
cb.setText(""+list_sted.get(i));
cb.setTextColor(R.color.Black);
cb.setTextAppearance(getBaseContext(), android.R.attr.checkboxStyle);
checkbox_lay.addView(cb);
}
You can't do this.
cb.setTextColor(R.color.Black);
Use this one.
cb.setTextColor(Color.BLACK);
or
cb.setTextColor(Color.parseColor("#000000"));
Try using this:
cb.setTextColor(Color.BLACK);
or From color.xml
cb.setTextColor(getResources().getColor(R.color.black));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.