我正在尝试制作一个用户可以在一组按钮上滑动或拖动手指以执行点击的应用程序。我试过onTouch
了,MotionEvent.ACTION_MOVE
但我似乎无法让它工作。按钮根本不按。这是代码:
public boolean onTouch(View v, MotionEvent arg1) {
if (arg1.getAction() == MotionEvent.ACTION_MOVE) {
switch (v.getId()) {
case R.id.key1:
key1.performClick();
break;
case R.id.key2:
key2.performClick();
break;
case R.id.key3:
key3.performClick();
break;
case R.id.key4:
key4.performClick();
break;
case R.id.key5:
key5.performClick();
break;
case R.id.key6:
key6.performClick();
break;
case R.id.key7:
key7.performClick();
break;
case R.id.key8:
key8.performClick();
break;
}
}
return true;
}