My checkbox does not appear in my CheckedTextView

前端 未结 2 779
醉话见心
醉话见心 2021-02-12 10:25

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_MODE_SI

相关标签:
2条回答
  • 2021-02-12 11:02

    (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"
     />
    
    0 讨论(0)
  • 2021-02-12 11:13

    you can have your own checkbox.xml in drawable folder then you can write it as android:checkMark = "@drawable/checkbox"

    0 讨论(0)
提交回复
热议问题