Android滑动事件与RecyclerView的item点击事件的冲突

2019-06-24 06:21:03

参看链接 Android滑动事件与RecyclerView的item点击事件的冲突

问题:RecyclerView列表显示,我滑动这个列表的item时,会触发item的点击事件
解决:调用RecyclerView的addOnItemTouchListener()监听,根据滑动的距离判断是否相应点击事件
 recyclerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {           public float y1,y2,x2,x1;           @Override
           public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {               if (e.getAction() == MotionEvent.ACTION_DOWN) {
                   x1 = e.getX();
                   y1 = e.getY();
               }               if (e.getAction() == MotionEvent.ACTION_UP) {
                   x2 = e.getX();
                   y2 = e.getY();                   if (Math.abs(x1 - x2) < 6) {                       return false;// 距离较小,当作click事件来处理
                   }                   if(Math.abs(x1 - x2) >60){  // 真正的onTouch事件
                       return true;
                   }
               }              return false;

           }           @Override
           public void onTouchEvent(RecyclerView rv, MotionEvent e) {

           }           @Override
           public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {

           }
       });

         

             


  • 2020-05-24 08:10:18

    echarts标题(title)配置

    show:true,//显示策略,默认值true,可选为:true(显示) | false(隐藏) text: '主标题',//主标题文本,'\n'指定换行 link:'',//主标题文本超链接,默认值true target: null,//指定窗口打开主标题超链接,支持'self' | 'blank',不指定等同为'blank'(新窗口) subtext: '副标题',//副标题文本,'\n'指定换行 sublink: '',//副标题文本超链接

  • 2020-06-02 08:57:12

    clipboard复制成功但是粘贴板是空的

    将文本复制到剪贴板应该不难。配置它不需要几十个步骤,也不需要加载数百KB的js文件 。但最重要的是,它不应该依赖Flash或任何臃肿的框架。这就是clipboard.js存在的原因。