Mam*_*dar 0 android multi-touch ontouchlistener
如果我在视图中有两个按钮,并且我想同时为这两个按钮启用OntouchListener,我的意思是触摸第一个按钮启动一个任务并按住第一个按钮触摸第二个按钮启动另一个任务.怎么做?等待帮助.
您可以将onTouchListener添加到该视图,该视图将处理多次触摸.
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
//first finger went down
break;
case MotionEvent.ACTION_MOVE:
//a touch placement has changed
break;
case MotionEvent.ACTION_UP:
//first finger went up
break;
case MotionEvent.ACTION_CANCEL:
//gesture aborted (I think this means the finger was dragged outside of the touchscreen)
break;
case MotionEvent.ACTION_POINTER_DOWN:
//second finger (or third, or more) went down.
break;
case MotionEvent.ACTION_POINTER_UP:
//second finger (or more) went up.
break;
default: break;
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
检查在相应的案例中是否单击了您的按钮.
| 归档时间: |
|
| 查看次数: |
1661 次 |
| 最近记录: |