如果gridview滚动顶部或底部,我想删除所有数据并重新加载其他数据,但我不知道如何获得向上或向下滚动状态?我尝试使用
@Override
public boolean onTouchEvent(MotionEvent event)
获取状态,但onTouchEvent
未运行。
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;
}
}
});