3

私は OnTouchListener を使用して、ex のマルチタッチ イベントをキャプチャしています。3本指タップで、2本指まで検出できました。ieevent.getPointerCount()は 2 まで返しますonTouchEvent()。これを処理するための他の API はありますか? テスト デバイスで 3 本指タップ検出を有効にしました。getPointerCount() は、Android 4.1.2 を搭載した Motorola Droid では機能しますが、Android 4.0.3 を搭載した HTC One V では機能しませ

package com.example.toucheventsample;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.VideoView;

public class TouchEventActivity extends Activity implements OnTouchListener{

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    VideoView videoView = (VideoView) findViewById(R.id.video);
    videoView.setOnTouchListener(this);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.touch_event, menu);
    return true;
}

public boolean handleTouchEvent(MotionEvent event) {
    boolean handled = true;
    int action = event.getAction();
    int count = event.getPointerCount();
    switch (action & MotionEvent.ACTION_MASK) {

        case MotionEvent.ACTION_POINTER_UP:
            if (3 == count) {
                // handle 3 finger tap
            }
            break;
    }
    return handled;
}

@Override
public boolean onTouch(View view, MotionEvent event) {
    int count = event.getPointerCount();
    handleTouchEvent(event);
    return true;
}
}
4

0 に答える 0