你的位置:首页 > 操作系统

[操作系统]android OnTouchListener 按下与抬起


写法一:

 1 private OnTouchListener pressOnTouchListener = new OnTouchListener(){ 2  3     @Override 4     public boolean onTouch(View view, MotionEvent event) { 5       // TODO Auto-generated method stub 6       switch (event.getAction()){ 7       case MotionEvent.ACTION_DOWN: 8         //按下 9         break;10       case MotionEvent.ACTION_UP:11         //抬起12         break;13         14       }15       return false;16     }17     18   };

 

写法二:

1   class myOntouchListener implements OnTouchListener{2 3     @Override4     public boolean onTouch(View arg0, MotionEvent arg1) {5       // TODO Auto-generated method stub6       return false;7     }8     9   }