C# android的Mono:Base64字符串到gridview中的图像

C# android的Mono:Base64字符串到gridview中的图像,c#,mono,xamarin.android,xamarin,C#,Mono,Xamarin.android,Xamarin,我有一个问题,就是如何将从Web服务礼貌地提供的数据集中获取的base64字符串转换为图像,然后将其显示在gridview上 我从Web服务传入的数据 <NewDataSet xmlns=""> <AvailableUsers diffgr:id="AvailableUsers1" msdata:rowOrder="0"> <sUserId>1</sUserId> <UserDesc>Mr. So

我有一个问题,就是如何将从Web服务礼貌地提供的数据集中获取的base64字符串转换为图像,然后将其显示在gridview上

我从Web服务传入的数据

<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>
这就是我目前的知识和理解停止的地方(我是这个领域的新手——以前做过一些web内容和轻javascript,但与此相比什么都没有)。我会礼貌地请别人给我写一个例子,或者至少给我指出一个真正涉及这个具体问题的教程

谢谢您的时间。

如果您看一下,我知道他在那里使用Base64图像转换

具体见:和:

使用以下代码从字符串加载图像:

var bytes = System.Convert.FromBase64String(base64);
var drawable = BitmapFactory.DecodeByteArray(bytes, 0, bytes.Length);

我通过使用listvew和自定义阵列适配器解决了问题

至于图像:

string base64 = item.UserIMG;

if (item.UserIMG != null) // If there's actually a string inside item.UserIMG
{
    System.IO.Stream s = new MemoryStream(Convert.FromBase64String(base64));

    byte[] arr = Convert.FromBase64String(base64);
    Drawable img = Drawable.CreateFromStream(s, null);

    ImageView UserAvatar = view.FindViewById<ImageView>(Resource.Id.imgView);
    UserAvatar.SetImageDrawable(img);
 }
 else  // If item.UserIMG is "" or null
    {
       ImageView UserAvatar = view.FindViewById<ImageView>(Resource.Id.imgView);
    }   
string base64=item.UserIMG;
if(item.UserIMG!=null)//如果item.UserIMG中实际上有一个字符串
{
System.IO.Stream s=新的MemoryStream(Convert.FromBase64String(base64));
字节[]arr=Convert.FromBase64String(base64);
Drawable img=Drawable.CreateFromStream(s,null);
ImageView UserAvatar=view.findviewbyd(Resource.Id.imgView);
UserAvatar.SetImageDrawable(img);
}
else//如果item.UserIMG为“”或null
{
ImageView UserAvatar=view.findviewbyd(Resource.Id.imgView);
}   

我忘了提到我使用的是Visual Studio 2010和Android.Bump的最新版本Mono?我真的需要帮助。
string base64 = item.UserIMG;

if (item.UserIMG != null) // If there's actually a string inside item.UserIMG
{
    System.IO.Stream s = new MemoryStream(Convert.FromBase64String(base64));

    byte[] arr = Convert.FromBase64String(base64);
    Drawable img = Drawable.CreateFromStream(s, null);

    ImageView UserAvatar = view.FindViewById<ImageView>(Resource.Id.imgView);
    UserAvatar.SetImageDrawable(img);
 }
 else  // If item.UserIMG is "" or null
    {
       ImageView UserAvatar = view.FindViewById<ImageView>(Resource.Id.imgView);
    }