Advertisement
minafaw3

vault_listadapter

Jun 30th, 2015
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.77 KB | None | 0 0
  1.  
  2. import android.content.Context;
  3. import android.view.LayoutInflater;
  4. import android.view.View;
  5. import android.view.ViewGroup;
  6. import android.widget.BaseAdapter;
  7. import android.widget.ImageView;
  8. import android.widget.TextView;
  9.  
  10. import com.validate.R;
  11.  
  12. import java.util.List;
  13.  
  14. import validate.com.classes.Vault_item_class;
  15.  
  16. /**
  17.  * Created by Mina on 30/06/2015.
  18.  */
  19. public class vault_listadapter extends BaseAdapter {
  20.     private List<Vault_item_class> vault_items;
  21.     private Context context;
  22.     private LayoutInflater inflater;
  23.  
  24.     TextView merchantName_tv, voucherType_tv, voucherName_tv, voucherDetail_tv, voucherValue_tv,
  25.             issueDate_tv, expiryDate_tv, voucherCode_tv;
  26.     ImageView barcode_imageview;
  27.  
  28.     public void vault_listadapter(Context context, List<Vault_item_class> vault_items) {
  29.         this.context = context;
  30.         this.vault_items = vault_items;
  31.         this.inflater = LayoutInflater.from(context);
  32.  
  33.     }
  34.  
  35.     @Override
  36.     public int getCount() {
  37.         return vault_items.size();
  38.     }
  39.  
  40.     @Override
  41.     public Vault_item_class getItem(int position) {
  42.         return vault_items.get(position);
  43.     }
  44.  
  45.     @Override
  46.     public long getItemId(int position) {
  47.         return position;
  48.     }
  49.  
  50.     @Override
  51.     public View getView(int position, View convertView, ViewGroup parent) {
  52.         ViewHolder holder;
  53.  
  54.         if (convertView == null) {
  55.             convertView = inflater.inflate(R.layout.vault_item, null, false);
  56.             holder = new ViewHolder();
  57.  
  58.             holder.merchantName_tv = (TextView) convertView.findViewById(R.id.merchantName_id);
  59.             holder.voucherName_tv = (TextView) convertView.findViewById(R.id.voucherName_id);
  60.             holder.voucherType_tv = (TextView) convertView.findViewById(R.id.voucherType_id);
  61.             holder.voucherDetail_tv = (TextView) convertView.findViewById(R.id.voucherDetails_id);
  62.             holder.voucherValue_tv = (TextView) convertView.findViewById(R.id.voucherVaule_id);
  63.             holder.issueDate_tv = (TextView) convertView.findViewById(R.id.issueDate_id);
  64.             holder.expiryDate_tv = (TextView) convertView.findViewById(R.id.expiryDate_id);
  65.             holder.voucherCode_tv = (TextView) convertView.findViewById(R.id.voucherCode_id);
  66.  
  67.             holder.barcode_imageview = (ImageView) convertView.findViewById(R.id.barcodeimg_id);
  68.  
  69.             convertView.setTag(holder);
  70.         } else {
  71.            holder = (ViewHolder) convertView.getTag();
  72.         }
  73.  
  74.  
  75.         return convertView;
  76.     }
  77.  
  78.     static class ViewHolder {
  79.         TextView merchantName_tv, voucherType_tv, voucherName_tv, voucherDetail_tv, voucherValue_tv,
  80.                 issueDate_tv, expiryDate_tv, voucherCode_tv;
  81.         ImageView barcode_imageview;
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement