0
這裏是包含圖像gridview的片段。最初我正在用20個物品加載網格。當用戶向下滾動網格時,我想通知數據集已更改,並應重新加載視圖。我添加了OnScrollListener。但它似乎並沒有工作。當我滾動列表時,它不調用onScroll方法。而且我還想知道什麼時候滾動,到達最終項目。這裏有什麼錯誤?Android中的GridView中的OnScrollListener
public class AllStoresFragment extends Fragment implements OnScrollListener{
GridView gridview;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
view = inflater.inflate(R.layout.allstores_fragment, container,
false);
gridview = (GridView) view.findViewById(R.id.grid_view_storestab);
gridview.setAdapter(new ImageAdapter(jsonresultinitial));
}
}
private void notifyMe()
{
((BaseAdapter) ((GridView) view.findViewById(R.id.grid_view_storestab))
.getAdapter()).notifyDataSetChanged();
gridview.setAdapter(new ImageAdapter(
jsonresult));
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
Log.v("first visible count",firstVisibleItem+"");
Log.v("visible count",visibleItemCount+"");
Log.v("total item count",totalItemCount+"");
notifyMe();
}