android开发中的双击事件
2 GestureDetector gd;
3 /** Called when the activity is first created. */
4 @Override
5 public void onCreate(Bundle savedInstanceState) {
6 super.onCreate(savedInstanceState);
7 setContentView(R.layout.main);
8 TextView tv = (TextView) this.findViewById(R.id.textView);
9 gd = new GestureDetector(this, new LearnGestureListener());
10
11 tv.setOnTouchListener(this);
12
13 }
14
15 @Override
16 public boolean onTouch(View arg0, MotionEvent arg1) {
17 // TODO Auto-generated method stub
18 return gd.onTouchEvent(arg1);
19 }
20
21 }
------------------------------------------
1 public class LearnGestureListener extends GestureDetector.SimpleOnGestureListener{
2 @Override
3 public boolean onSingleTapUp(MotionEvent ev) {
4 return true;
5 }
6
7 @Override
8 public void onShowPress(MotionEvent ev) {
9 }
10
11 @Override
12 public void onLongPress(MotionEvent ev) {
13 }
14
15 @Override
16 public boolean onScroll(MotionEvent e1, MotionEvent e2,
17 float distanceX, float distanceY) {
18 return true;
19 }
20
21 @Override
22 public boolean onDown(MotionEvent ev) {
23 return true;
24 }
25
26 @Override
27 public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
28 float velocityY) {
29 return true;
30 }
31 public boolean onDoubleTap(MotionEvent event){
32  
相关新闻>>
- 发表评论
-
- 最新评论 更多>>