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是一个 StateList 可绘制对象,我用来在 GridView 的选定项的左侧显示一个箭头。

此代码在任何至少具有 API 级别 11 (Honeycomb) 的 Android 设备上都能完美运行。在具有以前版本的设备上,当我检查 GridView 上的项目时,箭头没有出现。

经过一些调试后,我注意到 GridView 没有将按下的子项设置为已选中(在 API 级别 11+ 上发生的事情),因此不显示箭头。

任何想法为什么会发生这种情况?

4

0 回答 0