1imageButton.setOnTouchListener(new OnTouchListener() {
2 @Override
3 public boolean onTouch(View v, MotionEvent event) {
4 if(event.getAction() == MotionEvent.ACTION_UP){
5
6 // Do what you want
7 return true;
8 }
9 return false;
10 }
11});
12
1private View.OnTouchListener handleTouch = new View.OnTouchListener() {
2
3 @Override
4 public boolean onTouch(View v, MotionEvent event) {
5
6 int x = (int) event.getX();
7 int y = (int) event.getY();
8
9 switch (event.getAction()) {
10 case MotionEvent.ACTION_DOWN:
11 Log.i("TAG", "touched down");
12 break;
13 case MotionEvent.ACTION_MOVE:
14 Log.i("TAG", "moving: (" + x + ", " + y + ")");
15 break;
16 case MotionEvent.ACTION_UP:
17 Log.i("TAG", "touched up");
18 break;
19 }
20
21 return true;
22 }
23};
24