Reputation: 1
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);
}
Upvotes: 0
Views: 319
Reputation: 18933
You can't do this.
cb.setTextColor(R.color.Black);
Use this one.
cb.setTextColor(Color.BLACK);
or
cb.setTextColor(Color.parseColor("#000000"));
Upvotes: 3
Reputation: 4683
Try using this:
cb.setTextColor(Color.BLACK);
or From color.xml
cb.setTextColor(getResources().getColor(R.color.black));
Upvotes: 0