Hi, I've implemented a custom CheckBox view and faced a probelm with adding text to it.
Here's my implementation: public class MyCheckBox extends CheckBox{ private int imgResourceFocusedChecked, imgResourceFocusedNotChecked, imgResourceNotFocusedChecked, imgResourceNotFocusedNotChecked; public MyCheckBox(Context context){ super(context); } public MyCheckBox(Context context, AttributeSet attrs) { super(context, attrs); init(attrs); } public MyCheckBox(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(attrs); } private void init(AttributeSet attrs){ TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.MyCheckBox); imgResourceFocusedChecked = a.getResourceId (R.styleable.MyCheckBox_checkboxFocusedChecked, -1); imgResourceFocusedNotChecked = a.getResourceId (R.styleable.MyCheckBox_checkboxFocusedNotChecked, -1); imgResourceNotFocusedChecked = a.getResourceId (R.styleable.MyCheckBox_checkboxNotFocusedChecked, -1); imgResourceNotFocusedNotChecked = a.getResourceId (R.styleable.MyCheckBox_checkboxNotFocusedNotChecked, -1); strResourceText = a.getResourceId (R.styleable.MyCheckBox_checkboxText, -1); } public void onDraw(Canvas canvas){ if (this.isChecked()){ if (this.isFocused()){ this.setBackgroundResource(imgResourceFocusedChecked); } else { this.setBackgroundResource(imgResourceNotFocusedChecked); } } else { if (this.isFocused()){ this.setBackgroundResource(imgResourceFocusedNotChecked); } else { this.setBackgroundResource(imgResourceNotFocusedNotChecked); } } } } Then from my layout xml I do something like: <MyCheckBox android:id="@+id/checkBox" android:layout_width="32px" android:layout_height="32px" android:text="This is a check box." cb:checkboxFocusedChecked="@drawable/cb_focused_checked" cb:checkboxFocusedNotChecked="@drawable/cb_focused_not_checked" cb:checkboxNotFocusedChecked="@drawable/cb_not_focused_checked" cb:checkboxNotFocusedNotChecked="@drawable/ cb_not_focused_not_checked" style="@style/myStyle"/> However, the text never comes up. Using the same technique with Button and EditText views works fine , but not with check boxes. Hope to get an advice of how to implement the proper behaviour. Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---