我想为两个按钮实现 OnTouchEvent 并获取 同时 MotionEvent.ACTION_MOVE 函数。
我实现了 onTouchEvent 但不起作用
left = (Button)findViewById(R.id.button1);
right = (Button)findViewById(R.id.button2);
left.setOnTouchListener(this);
right.setOnTouchListener(this);
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
if (event.getAction() == MotionEvent.ACTION_DOWN) {
if(v.getId()==R.id.button1){
Log.i("left", "moved!");
}
if(v.getId()==R.id.button2){
Log.i("right", "move!");
}
}
return false;
}
在AndroidManifest.xml中
<uses-feature android:name="android.hardware.touchscreen.multitouch"
android:required="true" />
请帮我解决这个问题。
最佳答案
http://www.passsy.de/activity_with_multitouch_for_buttons/可以帮助你,你用的是什么 Android 版本?
关于java - Android中如何同时触摸两个按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10139291/