安卓的觸摸方法–回調
當用戶觸摸的時候自動調用的方法
@Override
public boolean onTouchEvent(MotionEvent event) {
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
{
System.out.println("按下");
}
break;
case MotionEvent.ACTION_MOVE:
{
System.out.println("移動");
}
break;
case MotionEvent.ACTION_CANCEL:
{
System.out.println("取消");
}
break;
case MotionEvent.ACTION_OUTSIDE:
{
System.out.println("ACTION_OUTSIDE");
}
break;
case MotionEvent.ACTION_UP:
{
System.out.println("彈起");
}
break;
default:
break;
}
return super.onTouchEvent(event);
}