根据文档,我提出了以下内容....
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.我在这里缺少什么?
答案 0 :(得分:1)
您从重写的onTouch事件返回false,该事件将事件作为未处理事件发送回链。您需要返回true,证明您自己已经处理过。 :)