Stop scrolling in a listview when user touches the list - android

android, android-listview, scroll

Solution

Use `smoothScrollBy`.

@Override 
public boolean onTouchEvent(MotionEvent ev) 
{ 
    switch (ev.getAction()) 
    {
        case MotionEvent.ACTION_UP:
            this.smoothScrollBy(0, 0); 
            break; 
    } 
    return super.onTouchEvent(ev);
}

Problem

I have a list view that contains about 30 items. When I scroll it down it just goes to the very bottom of the list and does not stop when the user touches the list. Is there a method to stop the scrolling when the list view is touched and at the same time user should be able to navigate using onItemClick(already handled).. Thank you!

Original source