Advertisement
banyucenter

HotelListAdapter.cs

Nov 20th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.69 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 HotelListAdapter : BaseAdapter<Hotel>
  15.     {
  16.         public HotelListAdapter()
  17.         {
  18.         }
  19.         Activity context;
  20.         List<Hotel> list;
  21.  
  22.         public HotelListAdapter(Activity _context, List<Hotel> _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 Hotel 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.ListHotelRow, parent, false);
  51.  
  52.  
  53.             Hotel item = this[position];
  54.             //view.FindViewById<TextView>(Resource.Id.HargaTiket).Text = item.harga_tiket;
  55.             view.FindViewById<TextView>(Resource.Id.NamaHotel).Text = item.nama_hotel;
  56.             view.FindViewById<TextView>(Resource.Id.AlamatHotel).Text = item.alamat;
  57.  
  58.             using (var imageView = view.FindViewById<ImageView>(Resource.Id.FotoHotel))
  59.             {
  60.                 string url = Android.Text.Html.FromHtml(item.foto).ToString();
  61.  
  62.                 //Download and display image
  63.                 Koush.UrlImageViewHelper.SetUrlDrawable(imageView,
  64.                                                         url, Resource.Drawable.loadimage);
  65.             }
  66.             return view;
  67.         }
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement