1

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>

また、この「getAmazingView」メソッドが必要になる場合もあります。

@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;
    }

クリックされていない場合: https://www.dropbox.com/s/iu3epknzutpa4jq/device-2014-02-21-175429.png

クリック時: https ://www.dropbox.com/s/xv9285pcb7wuzp9/device-2014-02-21-175449.png

いつ

ありがとう..

4

0 に答える 0