【发布时间】:2015-11-14 13:10:12
【问题描述】:
我在 [img_url] 字段中的 Json 中有图像 url。
我需要用ParseandDisplay方法下载
解析和显示:
private void ParseAndDisplay1(JsonValue json)
{
//ImageButton product = FindViewById<ImageButton>(Resource.Id.vugor);
TextView productname = FindViewById<TextView>(Resource.Id.posttittle);
TextView price = FindViewById<TextView>(Resource.Id.price);
TextView weight = FindViewById<TextView>(Resource.Id.weight);
productname.Click += delegate
{
var intent485 = new Intent(this, typeof(GoryachieRolli1));
StartActivity(intent485);
};
JsonValue firstitem = json[1];
//Console.Out.WriteLine(firstitem["post_title"].ToString());
productname.Text = firstitem["post_title"];
price.Text = firstitem["price"] + " грн";
weight.Text = firstitem["weight"] + "г";
}
我现在如何下载图片:
private Bitmap GetImageBitmapFromUrl1(string url)
{
Bitmap imageBitmap = null;
using (var webClient = new WebClient())
{
var imageBytes = webClient.DownloadData(url);
if (imageBytes != null && imageBytes.Length > 0)
{
imageBitmap = BitmapFactory.DecodeByteArray(imageBytes, 0, imageBytes.Length);
}
}
return imageBitmap;
}
我需要在解析和显示中进行下载和显示
【问题讨论】:
-
只需在其他方法中添加对 GetImageBitmapFromUrl1() 的调用?
-
您是否使用 parse.com 或任何其他网络服务作为 url
-
是的,像这样@Jason