0

I have a gesture listener interfering with a listView scroll. "On Finger Down" action won't stop a listView scroll once it started, so I was going to write it into code.

I can't find a method to stop a listView when finger touches the list?

I want to do it here:

    public boolean onDown(MotionEvent e) {

        // Stop Scroll here!

        return true;
    }

Is this possible

TheLettuceMaster
  • 15,594
  • 48
  • 153
  • 259

1 Answers1

1

Use this:

listView.setOnTouchListener(new OnTouchListener() {

public boolean onTouch(View v, MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_MOVE) {
        return true; // Indicates that this has been handled by you and will not be forwarded further.
    }
    return false;
}

});

Then ListView will react to clicks, but will not change scroll position.

Taken from this solution

Community
  • 1
  • 1
Udi Oshi
  • 6,787
  • 7
  • 47
  • 65
  • Thanks; everywhere I try to put it says I need to remove `@Override`. Where is this method placed? I am using a `ListFragment`. – TheLettuceMaster Jun 12 '13 at 19:27
  • 1
    I have just edited my answer. so you can implement it anonymously on your listView instance. – Udi Oshi Jun 12 '13 at 19:28
  • can't really understand your goal by using nested class in listview class. create new question here so other people might help you. i'll have a look also and help you as much as i can. – Udi Oshi Jun 12 '13 at 19:37
  • I have a question already worth 200 bounty points. Here it is; you actually fixed two thirds of the issue, but the biggest thing remains: http://stackoverflow.com/questions/16971808/gesture-listener-affecting-listview-scroll – TheLettuceMaster Jun 12 '13 at 19:43