Programmatically styling Android's CheckBox
android, checkbox, styling
Solution
I've arrived here looking for styling the text of the CheckBox instead of the Drawable, and I find the solution by another way. But hey! Let me share the solution to the myself of the future.
Instead of:
CheckBox cb = new CheckBox(this, null, R.style.yourstyle);
Use:
CheckBox cb = new CheckBox(this);
cb.setTextAppearance(this, R.style.yourstyle);
Hope it helps to solve the topic of the question!
Problem
I got a class which extends Activity and programmatically adding some View items. ``` CheckBox checkBox = new CheckBox(this, null, android.R.style.Widget_CompoundButton_Star); ``` I'd like to set some checkBoxes styled as the Android SDK stars. I can't see any check box after I set its style to that Widget_CompoundButton_Star. Although that SDK style apparently works when directly placing in a xml. Am I missing something here? THX // As Pragnani said. Using `android.R.attr.starStyle` instead works.