I have a problem with converting some base64 string that I get from a dataset politely served by a webservice into an image and thereafter displaying it on a gridview.
My incoming data from a webservice
<NewDataSet xmlns="">
<AvailableUsers diffgr:id="AvailableUsers1" msdata:rowOrder="0">
<sUserId>1</sUserId>
<UserDesc>Mr. Someone</UserDesc>
</AvailableUsers>
<AvailableUsers diffgr:id="AvailableUsers2" msdata:rowOrder="1" diffgr:hasChanges="modified">
<sUserId>2</sUserId>
<UserDesc>Mr. Someone 2</UserDesc>
<UserIMG>
// A base64 string is here but let's not bother ourselves with that here...
</UserIMG>
</AvailableUsers>
</NewDataSet>
My Image Adapter
class ImageAdapter : BaseAdapter
{
Context context;
public ImageAdapter(Context c)
{
context = c;
}
public override int Count
{
get { return thumbIds.Length; }
}
public override Java.Lang.Object GetItem(int position)
{
return null;
}
public override long GetItemId(int position)
{
return 0;
}
// create a new ImageView for each item referenced by the Adapter
public override View 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 GridView.LayoutParams(150, 150);
imageView.SetScaleType(ImageView.ScaleType.CenterCrop);
imageView.SetBackgroundColor(Color.Aqua);
}
else
{
imageView = (ImageView)convertView;
}
imageView.SetImageResource(thumbIds[position]);
return imageView;
}
int[] thumbIds = {
Resource.Drawable.sample_0, Resource.Drawable.sample_1, Resource.Drawable.sample_2, Resource.Drawable.sample_3
};
}
Here is where my current knowledge and understanding stops (I am a newbie on the field – did some web stuff and light javascript before but nothing compared to this). I would politely ask someone to write me up an example or at least point me to a tutorial that actually dabbles in this specific problem.
Thank you for your time.
I resolved my problem by using a listvew and custom array adapter.
As for the images: