Android ListView单击单个项目将获得ListView的所有项目';s选择器

Android ListView单击单个项目将获得ListView的所有项目';s选择器,android,android-listview,android-selector,android-background,Android,Android Listview,Android Selector,Android Background,我有一个名为AmazingListView的ListView,我为这个ListView分配了一个选择器。例如,在Android 4.1.2中,没有问题,但在Android 2.3.6中,当我单击一个项目时,所有项目都显示为已单击。在单击事件和调用指定方法时,没有问题。我认为这是源于选择器。我将我的列表视图和选择器放在下面,非常感谢您的帮助: <com.foound.widget.AmazingListView android:id="@+id/amazing_lv" and

我有一个名为AmazingListView的ListView,我为这个ListView分配了一个选择器。例如,在Android 4.1.2中,没有问题,但在Android 2.3.6中,当我单击一个项目时,所有项目都显示为已单击。在单击事件和调用指定方法时,没有问题。我认为这是源于选择器。我将我的列表视图和选择器放在下面,非常感谢您的帮助:

<com.foound.widget.AmazingListView
    android:id="@+id/amazing_lv"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:listSelector="@drawable/list_selector_menu_list_view"
    android:cacheColorHint="@android:color/transparent"
    android:choiceMode="singleChoice"/>
未单击时:

单击时:

什么时候

谢谢

<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:state_pressed="true" android:drawable="@color/fff42f2d"/>

</selector>
<color name="fff42f2d">#fff42f2d</color>
@Override
    public View getAmazingView(int position, View convertView, ViewGroup parent) {
        View res = convertView;
        if (res == null) res = activity.getLayoutInflater().inflate(R.layout.menu_item, null);

        // set background of this item text view
        Bitmap itemBmp = aUrl;
        if (Build.VERSION.SDK_INT >= 16) {
            res.setBackground(new BitmapDrawable(getResources(), itemBmp));
        } else {
            res.setBackgroundDrawable(new BitmapDrawable(getResources(), itemBmp));
        }

        TextView lName = (TextView) res.findViewById(R.id.lName);
        TextView lYear = (TextView) res.findViewById(R.id.lYear);

        Items composer = getItem(position);
        lName.setText(composer.title);
        lYear.setText(composer.summary);

        return res;
    }