0

I'm trying to completely disable SwipeRefreshLayout when inside the onLongClick of an item of the ListView.

I'm currently using setEnabled(false) but sometimes the swipe gesture get recognized anyways.

What could i try to stop this behaviour?

Luca Vitucci
  • 3,674
  • 4
  • 36
  • 60
  • can you post your code? you can unregister your swipe listiner by setting the `onTouch` listiner of your view to `null` – Sagar Pilkhwal Sep 26 '14 at 14:02
  • sorry didn't see you already tried setEnabled. Deleted my answer. – arne.jans Nov 03 '14 at 15:39
  • @Luca Vitucci Late reply:Try this http://code2concept.blogspot.in/2015/05/lollipop-swiperefreshlayout-with-loader.html – Nitesh Tiwari May 27 '15 at 07:05
  • Hi, Luca, did you ever figured this out ? I want to disable the SwipeRefreshLayout when user clicks long click on an item in recyclerview, but it doesn't seem to work using setEnabled(false) for the first time. Only after the click is finished it is disabled. – Gilad Eshkoli Apr 19 '16 at 06:59

2 Answers2

0

I think doing this in onLongClick is too late to lock the SwipeRefreshLayout as the user-interaction is already happening.

You could e.g. look into somehow slightly increasing the touch slop value of your ListView to suppress accidental swipes.

Look over here for discussion: Android ACTION_MOVE Threshold

Community
  • 1
  • 1
arne.jans
  • 3,798
  • 2
  • 22
  • 27
0
swipeLayout.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                // Your condition.
                return true;
            }
        });