码迷,mamicode.com
首页 > 其他好文 > 详细

PullToRefreshListView监听右划手势

时间:2015-04-29 17:17:28      阅读:104      评论:0      收藏:0      [点我收藏+]

标签:listview   右划   

在PullToRefreshListView中监听右划的动作并且监听到右划之后结束当前Activity
代码如下:

final GestureDetector gestureDetector = new GestureDetector(this, new GestureDetector.OnGestureListener() {

            @Override
            public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                // TODO Auto-generated method stub

                float x = e2.getX() - e1.getX(); 
                if (x > 500) {
                    onBackPressed();
                }
                return true;
            }

            @Override
            public boolean onDown(MotionEvent e) {
                // TODO Auto-generated method stub
                return false;
            }

            @Override
            public void onShowPress(MotionEvent e) {
                // TODO Auto-generated method stub

            }

            @Override
            public boolean onSingleTapUp(MotionEvent e) {
                // TODO Auto-generated method stub
                return false;
            }

            @Override
            public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
                // TODO Auto-generated method stub
                return false;
            }

            @Override
            public void onLongPress(MotionEvent e) {
                // TODO Auto-generated method stub

            }
        });
        listView.getRefreshableView().setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {

                return gestureDetector.onTouchEvent(event);
            }
        });

PullToRefreshListView监听右划手势

标签:listview   右划   

原文地址:http://blog.csdn.net/ithouse/article/details/45367421

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!