Just need a clue for the challenge


#1

I could find a solution that someone else has posted but I just need a clue to figure out my own solution
I have implemented an android.view.ViewTreeObserver.OnScrollChangedListener and I am wondering if I am barking up the wrong tree (pun intended)

It seems that I need some sort of listener and that listener should tell me when the user scrolls
anyway here is my solution so far. Notice that the PhotoGalleryFragment class implements onScrollChangedListener

public class PhotoGalleryFragment extends Fragment implements OnScrollChangedListener
{
private GridView mGridView;
private static Context context;
private ArrayList<GalleryItem> mItems;
public static final String TAG ="PhotoGalleryFragment";
private static PhotoGalleryFragment galleryInstance= new PhotoGalleryFragment();

	private PhotoGalleryFragment()
	{}

	public static PhotoGalleryFragment getInstance()
	{return galleryInstance;}
	
		@Override
		public void onCreate(Bundle savedInstanceState)
		{
			super.onCreate(savedInstanceState);
			setRetainInstance(true);
			//Start the flicker fetcher thread running
			new FetchItemsTask().execute();
			//Get the context for all to view
			context= getActivity();
		}
		
		@Override
		public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
		{
		View v=inflater.inflate(R.layout.fragment_photo_gallery,container, false);
		mGridView=(GridView)v.findViewById(R.id.photo_gallery_gridview);
		setupAdapter();
		return v;
		}
		
		public void onScrollChanged()
		{
			GridView mGridView=getGridView();
			int lastVisible=32;
			int sizeOfList=64;
				while(lastVisible != sizeOfList)
				{
				lastVisible= mGridView.getLastVisiblePosition();   
				sizeOfList=getNumberOfItems();
				Log.d(TAG,String.format("The last visible position is %d and the bottom of list is %d", lastVisible, sizeOfList));	
				}	
		}
--------------------------------------
Blah blah code code blah blah blah
}		

#2

I have solved this