Advertisement
rachmadi

CustomListAdapter

Jun 4th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.73 KB | None | 0 0
  1. package com.futsal.skripsi.futsal;
  2.  
  3. /**
  4.  * Created by asus on 14/03/2016.
  5.  */
  6. import com.futsal.skripsi.futsal.R;
  7. import com.futsal.skripsi.futsal.AppController;
  8. import com.futsal.skripsi.futsal.Lapangan;
  9.  
  10. import java.util.List;
  11.  
  12. import android.app.ActionBar;
  13. import android.app.Activity;
  14. import android.content.Context;
  15. import android.graphics.Movie;
  16. import android.view.LayoutInflater;
  17. import android.view.View;
  18. import android.view.ViewGroup;
  19. import android.widget.BaseAdapter;
  20. import android.widget.CheckBox;
  21. import android.widget.ImageView;
  22. import android.widget.TextView;
  23.  
  24. import com.android.volley.toolbox.ImageLoader;
  25. import com.android.volley.toolbox.NetworkImageView;
  26.  
  27. import org.w3c.dom.Text;
  28.  
  29.  
  30. public class CustomListAdapter extends BaseAdapter {
  31.     private Activity activity;
  32.     private LayoutInflater inflater;
  33.     private List<Lapangan> lapanganItems;
  34.     ImageLoader imageLoader = AppController.getInstance().getImageLoader();
  35.  
  36.     public CustomListAdapter(Activity activity, List<Lapangan> movieItems) {
  37.         this.activity = activity;
  38.         this.lapanganItems = movieItems;
  39.     }
  40.  
  41.     @Override
  42.     public int getCount() {
  43.         return lapanganItems.size();
  44.     }
  45.  
  46.     @Override
  47.     public Object getItem(int location) {
  48.         return lapanganItems.get(location);
  49.     }
  50.  
  51.     @Override
  52.     public long getItemId(int position) {
  53.         return position;
  54.     }
  55.  
  56.     @Override
  57.     public View getView(int position, View convertView, ViewGroup parent) {
  58.  
  59.         if (inflater == null)
  60.             inflater = (LayoutInflater) activity
  61.                     .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  62.         if (convertView == null)
  63.             convertView = inflater.inflate(R.layout.list_row, null);
  64.  
  65.         if (imageLoader == null)
  66.             imageLoader = AppController.getInstance().getImageLoader();
  67.         NetworkImageView thumbNail = (NetworkImageView) convertView
  68.                 .findViewById(R.id.thumbnail);
  69.         TextView nama = (TextView) convertView.findViewById(R.id.nama);
  70.         TextView alamat = (TextView) convertView.findViewById(R.id.alamat);
  71.         TextView harga = (TextView) convertView.findViewById(R.id.harga);
  72.  
  73.         // getting movie data for the row
  74.         Lapangan m = lapanganItems.get(position);
  75.         System.out.println("m: " + m);
  76. //
  77.        // thumbnail image
  78.         thumbNail.setImageUrl(m.getThumbnailUrl(), imageLoader);
  79.  
  80.         // title
  81.         nama.setText(m.getNama());
  82.         System.out.println("getNama: " + m.getNama());
  83.         System.out.println("getAlamat: " + m.getAlamat());
  84.         alamat.setText(m.getAlamat());
  85.         harga.setText("Rp " + String.valueOf(m.getHarga()));
  86.  
  87.         return convertView;
  88.     }
  89.  
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement