Üzerinde çalıştığım bir projede dinamik oluşturduğum checkboxların theme üzerinde gözükmemesi ancak checked edildikten sonra fark edilmesi problemiyle karşılaştım. Bu sorunu gidermek için theme'i değiştirebilirdim ancak bu pek işime gelmedi, bende statelere göre checkboxların render edildiği imageleri değiştirme yoluna gittim. Umarım işinize yarar.
(Last day I came across a problem while using checkbox object. After that i decided to create my own custom checkbox then this morning i did it and wanted to share with you guys. With the code as can be seen below you can create your own custom checkbox too. What you need is paying some attention to StateListDrawable concept. I hope it will be remarkable detail for you.)
CheckBox myCheckbox = new CheckBox(this);
StateListDrawable stateList = new StateListDrawable();
int statePressed = android.R.attr.state_pressed;
int stateChecked = android.R.attr.state_checked;
stateList.addState(new int[] {-stateChecked}, new BitmapDrawable(BitmapFactory.decodeResource(getResources(), R.drawable.unchecked)));
stateList.addState(new int[] {stateChecked}, new BitmapDrawable(BitmapFactory.decodeResource(getResources(), R.drawable.checked)));
stateList.addState(new int[] {statePressed}, new BitmapDrawable(BitmapFactory.decodeResource(getResources(), R.drawable.pressed)));
myCheckbox.setButtonDrawable(stateList);
İyi çalışmalar.