今天测试CheckedTextView竟然不显示
<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"
/>
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
利用上面的设置竟然不显示
查看了一下 在属性里面 竟然要:
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
Reference1:
http://stackoverflow.com/questions/2354488/checkedtextview-set-to-checked-oncreate-in-listview
setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
, you need to use the
setSelection()
method on ListView
to indicate which get checked
Reference2:
Q: 如果要把CheckedTextView这个控件集成到一个listactivity中,如何判断各行的text被checked?
A:
CheckedTextView vs = (CheckedTextView)listView.getChildAt(0);
Log.d("-----", vs.isChecked() + "");