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"
したがって、実行時にこれらの値を設定する必要があります。