views:

1610

answers:

1

Hi all, I'm trying to do something after scrolling stopped.So, I tried using OnScrollListener#onScrollStateChanged(SCROLL_STATE_IDLE) to detect when the scrolling stopped(either TOUCH_SCROLL or FLING)(at 1.5 it's runs as i expect). But when it runs on 2.0, onScrollStateChanged can't received the event after releasing the finger.Is there any callback or anyway to detect that event?

+6  A: 

Hi

Try using the setOnScrollListener and implement the onScrollStateChanged with scrollState == 0 ... do what you need to do...

setOnScrollListener(new OnScrollListener(){
    public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
      // TODO Auto-generated method stub
    }
    public void onScrollStateChanged(AbsListView view, int scrollState) {
      // TODO Auto-generated method stub
      if(scrollState == 0) Log.i("a", "scrolling stopped...");
    }
  });
}
PHP_Jedi
instead of hardcode equals 0, use OnScrollListener.SCROLL_STATE_IDLEThis is going to work if you are trying to detect when the scrolling stops... if you are trying to detect when the finger/fling is not touching the screen anymore, that would be a diffrent approach..
PHP_Jedi
I just tested the above code with 2.0 and it works just fine...
PHP_Jedi