根据文档,我提出了以下内容....
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。我在这里缺少什么?