2

マルチタッチの問題に直面しています。問題は、画面上の 2 つのボタンを同時にタッチできることです。

この質問は、このフォーラムで何度か聞かれることを知っています。唯一の解決策はandroid:splitMotionEvents="false"、親レイアウトで宣言することです。しかし、これを宣言した後、問題は残ります。ハードウェアの問題ですか、それともコードの問題ですか? ここでのポインタは大歓迎です。

4

2 に答える 2

0

これが私のために働いたものです。ボタンを含むすべての ViewGroup で android:splitMotionEvents="false" を設定することに加えて、これを MyAdapter.getView() に配置しました...

    view.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View cell, MotionEvent event) {
            // Process touches only if: 1) We havent touched a cell, or 2) This event is on the touched cell
            if (mTouchedCell == null || cell.equals(mTouchedCell)) {
                int action = event.getAction();
                if (action == MotionEvent.ACTION_DOWN) {
                    cell.startAnimation(mShrink);
                    mTouchedCell = cell;
                } else if (action == MotionEvent.ACTION_CANCEL) {
                    if (cell.equals(mTouchedCell)) {
                        cell.startAnimation(mGrow);
                    }
                    mTouchedCell = null;
                    return true;
                } else if (action == MotionEvent.ACTION_UP) {
                    cell.startAnimation(mFadeOut);
                    mTouchedCell = null;
                }
                return false;
            }
            return true;
        }
    });

...そしてもちろん、これはアダプターで...

private static View mTouchedCell = null;
于 2013-10-04T23:47:18.900 に答える