2

したがって、次の GridView 宣言があります。

<GridView
    android:id="@+id/payment_form_list"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:choiceMode="singleChoice"
    android:horizontalSpacing="0dp"
    android:listSelector="@null"
    android:numColumns="2"
    android:padding="0dp"
    android:stretchMode="columnWidth"
    android:verticalSpacing="0dp" />

GridView の各子は、次のレイアウトでアダプター上に構築されます。

<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:drawableLeft="@drawable/green_radio"
    android:drawablePadding="6dp"
    android:gravity="center_vertical"
    android:padding="16dp"
    android:textColor="@color/text_color"
    android:textSize="22sp" />

これ@drawable/green_radioは、GridView の選択した項目の左側に矢印を表示するために使用する StateList ドローアブルです。

このコードは、API レベル 11 (Honeycomb) 以上の Android デバイスで完全に機能します。以前のバージョンのデバイスでは、GridView の項目をチェックしても矢印が表示されませんでした。

いくつかのデバッグの後、GridView が押された子項目をチェック済みとして設定していないことに気付きました (API レベル 11 以降で発生するもの)。したがって、矢印は表示されません。

なぜこれが起こっているのですか?

4

0 に答える 0