My checkbox does not appear in my CheckedTextView
Here is how I setup my checked text view. How come no check box appeared?
I also added this but it had not effect: listView.setChoiceMode(ListView.CHOICE_MO开发者_如何学PythonDE_SINGLE);
<CheckedTextView
android:id="@+id/ctv_checktext"
android:layout_width="fill_parent"
android:paddingLeft="2px"
android:paddingRight="2px"
android:paddingTop="2px"
android:layout_height="wrap_content"
/>
(I'm answering my own question because it's undocumented in the Android API)
This is not enough:
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
You need to include the android:checkMark="?android:attr/listChoiceIndicatorMultiple" or else
<CheckedTextView
android:id="@+id/ctv_checktext"
android:layout_width="fill_parent"
android:paddingLeft="2px"
android:paddingRight="2px"
android:paddingTop="2px"
android:layout_height="wrap_content"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
/>
you can have your own checkbox.xml in drawable folder then you can write it as android:checkMark = "@drawable/checkbox"
精彩评论