Advertisement
banyucenter

WisataListAdapter.cs

Nov 8th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.75 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. //Adapter untuk load list view wisata by kabupaten
  13. namespace PariwisataJateng
  14. {
  15.     public class WisataListAdapter : BaseAdapter<Wisata>
  16.     {
  17.         public WisataListAdapter()
  18.         {
  19.         }
  20.         Activity context;
  21.         List<Wisata> list;
  22.  
  23.         public WisataListAdapter(Activity _context, List<Wisata> _list) : base()
  24.         {
  25.             this.context = _context;
  26.             this.list = _list;
  27.         }
  28.  
  29.         public override int Count
  30.         {
  31.             get { return list.Count; }
  32.         }
  33.  
  34.         public override long GetItemId(int position)
  35.         {
  36.             return position;
  37.         }
  38.  
  39.         public override Wisata this[int index]
  40.         {
  41.             get { return list[index]; }
  42.         }
  43.  
  44.         public override View GetView(int position, View convertView, ViewGroup parent)
  45.         {
  46.             View view = convertView;
  47.  
  48.             // re-use an existing view, if one is available
  49.             // otherwise create a new one
  50.             if (view == null)
  51.                 view = context.LayoutInflater.Inflate(Resource.Layout.ListWisataRow, parent, false);
  52.  
  53.  
  54.             Wisata item = this[position];
  55.             //view.FindViewById<TextView>(Resource.Id.HargaTiket).Text = item.harga_tiket;
  56.             view.FindViewById<TextView>(Resource.Id.NamaWisata).Text = item.nama_wisata;
  57.             view.FindViewById<TextView>(Resource.Id.AlamatWisata).Text = item.alamat;
  58.  
  59.             using (var imageView = view.FindViewById<ImageView>(Resource.Id.FotoWisata))
  60.             {
  61.                 string url = Android.Text.Html.FromHtml(item.foto).ToString();
  62.  
  63.                 //Download and display image
  64.                 Koush.UrlImageViewHelper.SetUrlDrawable(imageView,
  65.                                                         url, Resource.Drawable.loadimage);
  66.             }
  67.             return view;
  68.         }
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement