4

バージョン 4.0 より前のデバイス、つまり ics で問題なく動作するアプリケーションを作成しましたが、ics より上では必要に応じて動作しません。私のアプリケーションでは、2 つのボタンで同時にマルチタッチを作成しようとしていましたが、バージョン 4.0 未満では完全に機能していました。action_mask の値は、オンタッチとオフタッチで 6 nd 5 でした.4.0 より上のバージョンでは 1, 2, 0 でした.なぜこれが?

enter code here

@override
public boolean ontouch(Event ev , MotionEvent event)    
{
    int actionResolved = event.getAction() & MotionEvent.ACTION_MASK;
    int action = paramMotionEvent.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK;
//  int actionShift = paramMotionEvent.getAction() & MotionEvent.ACTION_POINTER_INDEX_SHIFT;
    Log.i("fil", "action resolved" +actionResolved);
    if(i==MotionEvent.ACTION_DOWN)
    {

        Log.i("fil", "action down");
        Log.i("fil", "action down value" +MotionEvent.ACTION_DOWN);
    }


    if(actionResolved == 5);
    {

        Log.i("fil", "action resolved" +actionResolved);
        scannerview1.startAnimation(anim1);
        scannerView2.startAnimation(anim1);




    }   


    if(actionResolved ==6)
            {

            scannerView2.clearAnimation();
            scannerview1.clearAnimation();      
        }


return true;         
}
4

2 に答える 2

1

アクションダウンでポインターIDを使用して、上記の問題を解決しました。ただし、このコードはバージョン 4.0 未満では使用できません

ここに私のコードがあります

@override
public boolean ontouch(Event ev , MotionEvent event)    
{
    switch (event.getAction() & MotionEvent.ACTION_MASK) 
    {               
        case MotionEvent.ACTION_DOWN:
            Log.i("D3", "pid" +event.getPointerId(0));
            //Log.i("D3", "pid" +event.getPointerId(1));
            if(event.getPointerId(0)==0){

            }
            if(event.getPointerId(0)==1) 
            {
                scannerview1.startAnimation(anim1);
                scannerView2.startAnimation(anim1);
            }
            break;
        case MotionEvent.ACTION_UP:
            scannerView2.clearAnimation();
            scannerview1.clearAnimation();
            break;
    }
    return true;
}
于 2013-03-04T11:47:48.580 に答える
0

それ以外の

if(actionResolved == 5);

使用する

if(actionResolved == ACTION_POINTER_1_DOWN);

定数値は、API バージョン間で変更される場合があり、実際に変更されます。

MotionEvent.ACTION_MASK非推奨であることにも注意してください。代わりに「MotionEvent.ACTION_POINTER_INDEX_MASK」を使用する必要があります。

http://developer.android.com/reference/android/view/MotionEvent.html#ACTION_POINTER_INDEX_MASK

于 2013-03-02T10:52:16.530 に答える