1
2
3
4
5
6
7
8
9
10
11
|
@Override
public
boolean
dispatchTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
return
super
.dispatchTouchEvent(event);
}
@Override
public
boolean
onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
return
super
.onTouchEvent(event);
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
@Override
public
boolean
onInterceptTouchEvent(MotionEvent ev) {
// TODO Auto-generated method stub
return
super
.onInterceptTouchEvent(ev);
}
@Override
public
boolean
onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
return
super
.onTouchEvent(event);
}
@Override
public
boolean
dispatchTouchEvent(MotionEvent ev) {
// TODO Auto-generated method stub
return
super
.dispatchTouchEvent(ev);
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
public
class
MyTextView
extends
TextView{
private
final
String TAG = MyTextView.
class
.getSimpleName();
public
MyTextView(Context context) {
super
(context);
}
@Override
public
boolean
dispatchTouchEvent(MotionEvent event) {
switch
(event.getAction()) {
case
MotionEvent.ACTION_DOWN:
Log.d(TAG, TAG +
"dispatchTouchEvent+ACTION_DOWN"
);
break
;
case
MotionEvent.ACTION_POINTER_DOWN:
Log.d(TAG, TAG +
"dispatchTouchEvent+ACTION_POINTER_DOWN"
);
break
;
case
MotionEvent.ACTION_POINTER_UP:
Log.d(TAG, TAG +
"dispatchTouchEvent+ACTION_POINTER_UP"
);
break
;
case
MotionEvent.ACTION_MOVE:
Log.d(TAG, TAG +
"dispatchTouchEvent+ACTION_MOVE"
);
break
;
case
MotionEvent.ACTION_UP:
Log.d(TAG, TAG +
"dispatchTouchEvent+ACTION_UP"
);
break
;
}
return
super
.dispatchTouchEvent(event);
}
@Override
public
boolean
onTouchEvent(MotionEvent event) {
switch
(event.getAction()) {
case
MotionEvent.ACTION_DOWN:
Log.d(TAG, TAG +
"onTouchEvent+ACTION_DOWN"
);
break
;
case
MotionEvent.ACTION_POINTER_DOWN:
Log.d(TAG, TAG +
"onTouchEvent+ACTION_POINTER_DOWN"
);
break
;
case
MotionEvent.ACTION_POINTER_UP:
Log.d(TAG, TAG +
"onTouchEvent+ACTION_POINTER_UP"
);
break
;
case
MotionEvent.ACTION_MOVE:
Log.d(TAG, TAG +
"onTouchEvent+ACTION_MOVE"
);
break
;
case
MotionEvent.ACTION_UP:
Log.d(TAG, TAG +
"onTouchEvent+ACTION_UP"
);
break
;
}
return
super
.onTouchEvent(event);
}
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
public
class
MyLinearLayout
extends
LinearLayout {
private
final
String TAG = MyLinearLayout.
class
.getSimpleName();
public
MyLinearLayout(Context context) {
super
(context);
}
@Override
public
boolean
onInterceptTouchEvent(MotionEvent ev) {
switch
(ev.getAction()) {
case
MotionEvent.ACTION_DOWN:
Log.d(TAG, TAG +
"onInterceptTouchEvent+ACTION_DOWN"
);
break
;
case
MotionEvent.ACTION_POINTER_DOWN:
Log.d(TAG, TAG +
"onInterceptTouchEvent+ACTION_POINTER_DOWN"
);
break
;
case
MotionEvent.ACTION_POINTER_UP:
Log.d(TAG, TAG +
"onInterceptTouchEvent+ACTION_POINTER_UP"
);
break
;
case
MotionEvent.ACTION_MOVE:
Log.d(TAG, TAG +
"onInterceptTouchEvent+ACTION_MOVE"
);
break
;
case
MotionEvent.ACTION_UP:
Log.d(TAG, TAG +
"onInterceptTouchEvent+ACTION_UP"
);
break
;
}
return
super
.onInterceptTouchEvent(ev);
}
@Override
public
boolean
onTouchEvent(MotionEvent event) {
switch
(event.getAction()) {
case
MotionEvent.ACTION_DOWN:
Log.d(TAG, TAG +
"onTouchEvent+ACTION_DOWN"
);
break
;
case
MotionEvent.ACTION_POINTER_DOWN:
Log.d(TAG, TAG +
"onTouchEvent+ACTION_POINTER_DOWN"
);
break
;
case
MotionEvent.ACTION_POINTER_UP:
Log.d(TAG, TAG +
"onTouchEvent+ACTION_POINTER_UP"
);
break
;
case
MotionEvent.ACTION_MOVE:
Log.d(TAG, TAG +
"onTouchEvent+ACTION_MOVE"
);
break
;
case
MotionEvent.ACTION_UP:
Log.d(TAG, TAG +
"onTouchEvent+ACTION_UP"
);
break
;
}
return
super
.onTouchEvent(event);
}
@Override
public
boolean
dispatchTouchEvent(MotionEvent ev) {
switch
(ev.getAction()) {
case
MotionEvent.ACTION_DOWN:
Log.d(TAG, TAG +
"dispatchTouchEvent+ACTION_DOWN"
);
break
;
case
MotionEvent.ACTION_POINTER_DOWN:
Log.d(TAG, TAG +
"dispatchTouchEvent+ACTION_POINTER_DOWN"
);
break
;
case
MotionEvent.ACTION_POINTER_UP:
Log.d(TAG, TAG +
"dispatchTouchEvent+ACTION_POINTER_UP"
);
break
;
case
MotionEvent.ACTION_MOVE:
Log.d(TAG, TAG +
"dispatchTouchEvent+ACTION_MOVE"
);
break
;
case
MotionEvent.ACTION_UP:
Log.d(TAG, TAG +
"dispatchTouchEvent+ACTION_UP"
);
break
;
}
return
super
.dispatchTouchEvent(ev);
}
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
public
class
TestActivity
extends
Activity {
@Override
protected
void
onCreate(Bundle savedInstanceState) {
super
.onCreate(savedInstanceState);
MyLinearLayout layout =
new
MyLinearLayout(
this
);
MyTextView myTextView =
new
MyTextView(
this
);
myTextView.setText(
"touch event"
);
layout.addView(myTextView,
new
LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
setContentView(layout);
}
}
|