码迷,mamicode.com
首页 > 移动开发 > 详细

xamarin.Android ImageView 异步加载网络图片

时间:2016-06-03 18:38:35      阅读:1532      评论:0      收藏:0      [点我收藏+]

标签:

     /// <summary>
        /// 异步获取文件流
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public async Task<Stream> GetFileStreamAsync(string url)
        {
            try
            {
                System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
                var fileStream = await client.GetStreamAsync(url);
                return fileStream;
            }
            catch (Exception ex)
            {
                throw new WebServiceException(ex.Message);
            }
        }
     private async void SetImage(string url)
        {var stream = await GetFileStreamAsync(url);
            var imageView = FindViewById<ImageView>(Resource.Id.iv_userphoto_mycenter_myprofile);
            imageView.SetImageBitmap(BitmapFactory.DecodeStream(stream));
        }

 

xamarin.Android ImageView 异步加载网络图片

标签:

原文地址:http://www.cnblogs.com/mycing/p/5557050.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!