这是具有图像网格视图的片段。最初,我正在加载包含 20 个项目的网格。当用户向下滚动网格时,我想通知数据集已更改并应重新加载视图。我添加了 OnScrollListener。但这似乎不起作用。当我滚动列表时,它没有调用 onScroll 方法。而且我还想知道滚动何时到达终点。这里有什么错误?
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();
}