我正在尝试编程方式设置ListView中的CheckedTextView项目上的"android:checkMark"属性。运行我的应用程序时,我收到以下异常:
android.content.res.Resources$NotFoundException: Resource ID #0x101021a
资源ID为# 0x101021a对应于android.R.attr.listChoiceIndicatorMultiple,这恰好是我传递给我的CheckedTextView的值:
mCheckedTextView.setCheckMarkDrawable(android.R.attr.listChoiceIndicatorMultiple)
这不是从Java中实现的方法吗?我尝试过(并成功地)从XML布局中触发所需行为:
<CheckedTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:id="@android:id/text1" />
问题在于我不知道在编译时它应该是什么。
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
或者android:checkMark="?android:attr/listChoiceIndicatorSingle"
因此,我需要在运行时设置这些值。