Advertisement
banyucenter

CustomListWisataAdapter.cs

Nov 20th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.59 KB | None | 0 0
  1. using System;
  2. using Android.Widget;
  3. using Android.App;
  4. using System.Collections.Generic;
  5. using Android.Views;
  6. using Android.Media;
  7. using System.Net;
  8. using System.Threading.Tasks;
  9. using System.IO;
  10. using Android.Graphics;
  11.  
  12. namespace PariwisataJateng
  13. {
  14.     public class CustomListWisataAdapter : BaseAdapter<ListWisata>
  15.     {
  16.     public CustomListWisataAdapter()
  17.         {
  18.         }
  19.         Activity context;
  20.         List<ListWisata> list;
  21.  
  22.         public CustomListWisataAdapter(Activity _context, List<ListWisata> _list) : base()
  23.         {
  24.             this.context = _context;
  25.             this.list = _list;
  26.         }
  27.  
  28.         public override int Count
  29.         {
  30.             get { return list.Count; }
  31.         }
  32.  
  33.         public override long GetItemId(int position)
  34.         {
  35.             return position;
  36.         }
  37.  
  38.         public override ListWisata this[int index]
  39.         {
  40.             get { return list[index]; }
  41.         }
  42.  
  43.         public override View GetView(int position, View convertView, ViewGroup parent)
  44.         {
  45.             View view = convertView;
  46.  
  47.             // re-use an existing view, if one is available
  48.             // otherwise create a new one
  49.             if (view == null)
  50.                 view = context.LayoutInflater.Inflate(Resource.Layout.ListWisata, parent, false);
  51.  
  52.  
  53.             ListWisata item = this[position];
  54.             view.FindViewById<TextView>(Resource.Id.NamaListWisata).Text = item.nama_wisata;
  55.  
  56.  
  57.             using (var imageView = view.FindViewById<ImageView>(Resource.Id.FotoListWisata))
  58.             {
  59.                 string url = Android.Text.Html.FromHtml(item.foto).ToString();
  60.  
  61.                 //Download and display image
  62.                 Koush.UrlImageViewHelper.SetUrlDrawable(imageView,
  63.                                                         url, Resource.Drawable.loadimage);
  64.             }
  65.             return view;
  66.         }
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement