我的复选框不会出现在我的CheckedTextView我的、出现在、复选框、CheckedTextView

2023-09-06 01:41:34 作者:无可复制的我╮

下面是如何设置我检查文本视图。怎么会没有复选框出现?

我还添加了这一点,但它没有效果:         listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

 < CheckedTextView
 机器人:ID =@ + ID / ctv_checktext
 机器人:layout_width =FILL_PARENT
 机器人:以下属性来=2px的
 机器人:paddingRight =2px的
 机器人:paddingTop =2px的
 机器人:layout_height =WRAP_CONTENT
 />
 

解决方案

(我回答我的问题,因为它是无证Android的API中)

Android中CheckedTextView点击问题

这是不够的:

  listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
 

您需要包括机器人:对号=机器人:ATTR / listChoiceIndicatorMultiple 否则

 < CheckedTextView
 机器人:ID =@ + ID / ctv_checktext
 机器人:layout_width =FILL_PARENT
 机器人:以下属性来=2px的
 机器人:paddingRight =2px的
 机器人:paddingTop =2px的
 机器人:layout_height =WRAP_CONTENT
 机器人:对号=机器人:ATTR / listChoiceIndicatorMultiple
 />
 

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_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"
 />