0

ドキュメントに従って、私は次のことを思いつきました....

public class ZoomActivity extends Activity implements View.OnTouchListener{

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_zoom);
    View v = findViewById(R.id.textv);
    v.setOnTouchListener(this);
}
    @Override
public boolean onTouch(View arg0, MotionEvent arg1) {
    CharSequence text="";
    switch(arg1.getAction()){
    case (MotionEvent.ACTION_POINTER_DOWN):
        text = "Pointer Down ";
        break;
    case (MotionEvent.ACTION_DOWN):
        text = "Down Action ";
        break;
    }
    if(arg1.getPointerCount()>1){
      text = text + "Multiple Presses "+arg1.getPointerCount();
    }
    else{
        text = text + "Single Press";
    }
    if(arg1.getHistorySize() > 0){
        text = text + " Previous x is "+arg1.getHistoricalAxisValue(MotionEvent.AXIS_X, 0);
    }
    else{
        text = text + " First press";
    }
    int duration = Toast.LENGTH_LONG;
    Toast toast = Toast.makeText(getApplicationContext(), text, duration);
    toast.show();
    return false;
}
}

問題は、デバイスで実行すると getPointerCount が常に 1 になることです。ここで何が欠けていますか?

4

1 に答える 1