I am trying to use R.layout.simple_list_item_multiple_choice with ListView. CheckedTextView is used in simple_list_item_multiple_choice.xml, but how can I make the checkbox
You can assign your drawable to drawableLeft attribute, but it won't make you any good because it not support tinting. Instead I extended CheckedTextView like that:
public class LeftSideCheckedTextView extends CheckedTextView {
public LeftSideCheckedTextView(Context context) {
this(context, null, 0);
}
public LeftSideCheckedTextView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public LeftSideCheckedTextView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
Field mCheckMarkGravity = null;
try {
mCheckMarkGravity = this.getClass().getSuperclass().getDeclaredField("mCheckMarkGravity");
mCheckMarkGravity.setAccessible(true);
mCheckMarkGravity.set(this, Gravity.START);
} catch (Exception e) {
Logger.error(e);
}
}
}
Here I access the hidden field mCheckMarkGravity which is used inside CheckedTextView but have no access via style attributes, according to this bug ticket: https://code.google.com/p/android/issues/detail?id=174517