1
그리드보기의 손 끝 :무한 호출 할 때 나는 내가있는 gridview의 끝에 도달 할 때 뭔가를 할 수있는 다음 코드를 발견했습니다
GridView gridview = (YMAnimatedGridview) v.findViewById(R.id.my_gridview);
gridview.setAdapter(adapter);
final View footerView = mainView
.findViewById(R.id.my_grid_footer_view);
gridview.setOnScrollListener(new GridView.OnScrollListener() {
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
if (firstVisibleItem + visibleItemCount == totalItemCount) {
// last item in grid is on the screen, show footer:
fetchMoreItems();
}
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
것은 내가 도달했을 때,이다 이 메소드는 gridView의 끝에 계속 호출됩니다. ,
private void fetchMoreItems() {
Log.i(LOG_TAG, "Reached the end of grid view"); //for debbug purposes
Integer lastIndex = thumbnails.length; //This is a Bitmap array with the data I'm alredy showing
Cursor cursor = getData();
thumbnails = concat(thumbnails, new Bitmap[30]);
Integer lastIndexToRun = Math.min(30, cursor.getCount() - lastIndex);
for(int j = 0; j < lastIndexToRun; j++) {
Integer i = j + lastIndex;
cursor.moveToPosition(i);
thumbnails[i] = getThumbnail(i);
}
adapter.notifyDataSetChanged(); //This is the adapter used to fill the gridview
cursor.close();
}
나는() 메소드 내 실수가 fetchMoreItems에해야한다고 생각하지만의 GridView를 사용하여 내 처음이기 때문에, 나는 여러 번 호출 할 수있는 방법을 피할 필요