3

私の問題:ListViewsのアイテムをクリックすると、その状態が次の順序で変更されます:チェックされていない場合-チェックされていない、チェックされている、チェックされていない、チェックされているが、点滅したり点滅したりせずに単にチェックされると予想される

チェックされている場合:チェックされている - チェックされていない(問題ありません)

このバグは、 HoneyComb 以前のデバイスでのみ発生し、ICS ではすべて問題ありません

このバグは Android の組み込みメカニズムを指していると思います。もしそうなら、解決策はありますか?

私が持っているもの:

1) リストビュー ( multiChoice = true)
2) セレクター:

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

    <item  android:drawable="@color/main_listview_item_pressed_longpressed"
         android:state_checked="true"  />

ListViews の項目レイアウトに適用されます

3) 項目のレイアウト:

<com.sasha.medclock2.CheckedLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:paddingLeft="5dip"
        android:background="@drawable/list_item_selector"

        android:id="@+id/linerar_layout_checkable"
         >

        <TextView
            android:id="@+id/text1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@drawable/textview_selector"
             />

        <TextView
            android:id="@+id/text2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@drawable/textview_selector"
             />

        <TextView
            android:id="@+id/text3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@drawable/textview_selector"
             />

        <TextView
            android:id="@+id/text4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@drawable/textview_selector"
             />

    </com.sasha.medclock2.CheckedLinearLayout>

4) CheckedLinearLayout :

public class CheckedLinearLayout extends LinearLayout implements Checkable {
    private final static String TAG = "CheckableLinearLayout";

    private static final int[] CHECKED_STATE_SET = {
        android.R.attr.state_checked
    };

    private boolean checked = false;



    public CheckedLinearLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CheckedLinearLayout(Context context) {
        super(context);
    }

    @Override
    public boolean isChecked() {
        return checked;
    }

    @Override
    public void setChecked(boolean checked) {
        this.checked = checked;

        refreshDrawableState();

        //Propagate to childs
        final int count = getChildCount();
        for (int i = 0; i < count; i++) {
            final View child = getChildAt(i);
            if(child instanceof Checkable) {
                ((Checkable)child).setChecked(checked);
            }
        }
    }


    @Override
    protected int[] onCreateDrawableState(int extraSpace) {
        final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
        if (isChecked()) {
            mergeDrawableStates(drawableState, CHECKED_STATE_SET);
        }
        return drawableState;
    }

    @Override
    public void toggle() {
        this.checked = !this.checked;
    }
}

5)私はActionBarSherlocklibと同様に使用していますHoloEverywhere

6) ListView.setItemChecked(...) で ListViews のアイテムをチェックします。

助けてくれてありがとう、

4

1 に答える 1