mercredi 2 septembre 2015

Android checkboxes added by code don't have the right appearance?

I've got a really basic app in which I'm trying to insert dynamic checkboxes, and I can get them to appear, but they're not showing with the correct styling.

See below - Foo is in the LinearLayout by definition; Bar is being added programmatically. Foo is showing with a grey box for the check, Bar is showing with a white box.

Link to image...

Here's the code that's creating these:

for (Integer i=0; i < arArray.length;i++) {
    CheckBox cb = new CheckBox(getApplicationContext());
    cb.setText("Bar");
    cb.setTextColor(getResources().getColor(android.R.color.black));
    cb.setOnCheckedChangeListener(clListener);
    llDeckChecks.addView(cb);
}

I've tried setting the drawable to some android.R.drawable types, but nothing matches the Foo checkbox, so I'm entirely stumped at this point.




Aucun commentaire:

Enregistrer un commentaire