3

If gridview scroll top or bottom, I want to remove all data and reload other data but I don't know how to get the scroll up or down status? I try to use

 @Override    
public boolean onTouchEvent(MotionEvent event) 

get the status, but onTouchEvent is not run.

mygridview.setOnScrollListener(new OnScrollListener()
{         
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) 
{
}          

public void onScrollStateChanged(AbsListView view, int scrollState) 
{           
    switch (scrollState)
    {  
    case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:

       if (photolist_scroll_flag == 0)   //scroll up
       {
         if (has_loaded_item - page_item_num > 0)
         {
             LoadRemainingItems(); 
        }
      }
      else if (photolist_scroll_flag == 1)  //scroll down
      { 
        if (lastItem == view.getCount()) 
        {  
            if (has_loaded_item < listtotalitem)
            {    
                  LoadRemainingItems();  
            }    
         }  
     }
     break;  

     case OnScrollListener.SCROLL_STATE_FLING: 
        break;  

    case OnScrollListener.SCROLL_STATE_IDLE:
        break;  
    }
}      
}); 
John Sansom
  • 41,005
  • 9
  • 72
  • 84
fang99108
  • 39
  • 2
  • I didn't understand the question. Do you want to load new items when you hit the top or the bottom of the listview, or during the scroll itself? – Carlos Silva Aug 15 '11 at 04:42
  • scroll the GrideView/ListView,just scroll to the top or bottom,then load a new page data, old page will clean – fang99108 Aug 15 '11 at 06:03
  • If you Just want to detect GridView/ListView scrolling up or down, May this answer will help you http://stackoverflow.com/a/17017477/1908296 – ahmed hamdy May 27 '15 at 13:48

0 Answers0