裝載20圖像所以我一直試圖使它異步下載images.my應用程序運行緩慢和滯後和拖延列表視圖跑這麼落後,同時從互聯網上
public override View GetView(int position, View convertView,ViewGroup parent)
\t \t \t {
\t \t \t \t View view = convertView ?? _inflater.Inflate (Resource.Layout.textViewItems, parent, false);
\t \t \t \t
\t \t \t \t if (track.artwork_url != null) {
\t \t \t \t \t var imageBitmap = GetImageBitmapFromUrl(track.artwork_url);
\t \t \t \t \t if (imageBitmap != null && imageBitmap.Length > 0) {
\t \t \t \t \t \t var converterImage = BitmapFactory.DecodeByteArray (imageBitmap, 0, imageBitmap.Length);
\t \t \t \t \t \t viewHolder.Image.SetImageBitmap(converterImage);
\t \t \t \t \t }
\t \t \t \t } else {
\t \t \t \t \t viewHolder.Image.SetImageResource(Resource.Drawable.img1);
\t \t \t \t }
\t \t \t \t return view;
\t \t \t }
public static byte[] GetImageBitmapFromUrl(string url)
\t \t {
\t \t \t byte [] imageBitmap = null;
\t \t \t using (var webClient = new WebClient())
\t \t \t {
\t \t \t \t var imageBytes = webClient.DownloadData(url);
\t \t \t \t imageBitmap = imageBytes;
\t \t \t }
\t \t \t return imageBitmap;
\t }
所有圖片被加載在列表視圖(100px高度和寬度)。我也設置了ImageView.layout_width = 70dp和高度。 但我不能在列表視圖中向下滾動或向上滾動。因爲listview變得如此滯後和非常糟糕
我認爲問題在於GetImageBitmapFromUrl。怎麼修。
使用ImageLoader的LIB最好是universalimageloader https://github.com/nostra13/Android-Universal-Image-Loader –