我很难计算在屏幕的每个“一半”中进行了多少触摸。当我触摸上侧时,它计数正确,下侧也一样。但是,当我触摸上侧时,不要松开它,然后触摸下侧,那么它算错了,我的实现有什么问题?
myView.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
int action = event.getAction() & MotionEvent.ACTION_MASK;
if (action == MotionEvent.ACTION_DOWN) {
if(event.getY()<400)
{
}
else
{
}
}
if (action == MotionEvent.ACTION_UP) {
if(event.getY()<400)
{
zenbat=zenbat+1;
tv.setText(String.valueOf(zenbat));
}
if(event.getY()>400)
{
zenbat1=zenbat1+1;
tv1.setText(String.valueOf(zenbat1));
}
}
if (action == MotionEvent.ACTION_POINTER_DOWN) {
if(event.getY()<400)
{
}
else
{
}
}
if (action == MotionEvent.ACTION_POINTER_UP) {
if(event.getY()<400)
{
zenbat=zenbat+1;
tv.setText(String.valueOf(zenbat));
}
if(event.getY()>400)
{
zenbat1=zenbat1+1;
tv1.setText(String.valueOf(zenbat1));
}
}
return true;
}
});