Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- switch(event.getAction()) {
- case MotionEvent.ACTION_DOWN:
- if (mHandler != null) return true;
- mHandler = new Handler();
- mHandler.postDelayed(mAction, 10);
- break;
- case MotionEvent.ACTION_UP:
- if (mHandler == null) return true;
- mHandler.removeCallbacks(mAction);
- mHandler = null;
- break;
- }
- return false;
- }
- Runnable mAction = new Runnable() {
- @Override
- public void run() {
- //Do continuous task
- mHandler.postDelayed(this, 100);
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement