Hi:
I'm new to Android development and am trying to load images into a GridView via the ImageAdapter. The images must be downloaded and converted to bitmaps to accomplish this. My inclination was to do this in the override to the GetView method.
public override async Task GetView(int position, View convertView, ViewGroup parent)
{
ImageView imageView;
if (convertView == null)
{
// if it's not recycled, initialize some attributes
imageView = new ImageView(context);
imageView.LayoutParameters = new AbsListView.LayoutParams(150, 150);
imageView.SetScaleType(ImageView.ScaleType.CenterCrop);
imageView.SetPadding(8, 8, 8, 8);
}
else
{
imageView = (ImageView)convertView;
}
imageView.SetImageBitmap(await GetFromUri(position + this.start));
return imageView;
}
The above generates a "return type must be Android.Views.View" to match overridden member, . . . which is absolutely correct. It leads me to wonder if my approach of retrieving the bitmap asynchronously when the view is actually needed is even the right place to get it. Ideally, I want to load the initial page, then preload the next page of images.
In order to do this, I would need to be able to subscribe to some type of scroll or swipe event. Am I on the right track? Any hints on where to look?
Thanks.