Advertisement
Guest User

Untitled

a guest
Sep 11th, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.71 KB | None | 0 0
  1. package info.androidhive.materialdesign.activity;
  2.  
  3. import android.app.Activity;
  4. import android.content.Context;
  5. import android.view.LayoutInflater;
  6. import android.view.View;
  7. import android.view.ViewGroup;
  8. import android.widget.ArrayAdapter;
  9. import android.widget.ImageView;
  10. import android.widget.TextView;
  11. import android.widget.Toast;
  12.  
  13. import info.androidhive.materialdesign.R;
  14.  
  15. public class CustomAdapter extends ArrayAdapter<RowBean> {
  16.  
  17.     Context context;
  18.     int nazwiskaImages;
  19.     RowBean data[] = null;
  20.  
  21.     public CustomAdapter(Context context, int nazwiskaImages, RowBean[] data) {
  22.         super(context, nazwiskaImages, data);
  23.         this.nazwiskaImages = nazwiskaImages;
  24.         this.context = context;
  25.         this.data = data;
  26.     }
  27.  
  28.  
  29.  
  30.     @Override
  31.     public View getView(int position, View convertView, ViewGroup parent) {
  32.         View row = convertView;
  33.         RowBeanHolder holder = null;
  34.  
  35.         if(row == null)
  36.         {
  37.             LayoutInflater inflater = ((Activity)context).getLayoutInflater();
  38.             row = inflater.inflate(nazwiskaImages, parent, false);
  39.  
  40.             holder = new RowBeanHolder();
  41.             holder.avatar = (ImageView)row.findViewById(R.id.avatar);
  42.             holder.full_name = (TextView)row.findViewById(R.id.full_name);
  43.  
  44.             row.setTag(holder);
  45.         }
  46.         else
  47.         {
  48.             holder = (RowBeanHolder)row.getTag();
  49.         }
  50.  
  51.         RowBean object = data[position];
  52.         holder.full_name.setText(object.title);
  53.         holder.avatar.setImageResource(object.icon);
  54.  
  55.         return row;
  56.     }
  57.  
  58.     static class RowBeanHolder   {
  59.         public ImageView avatar;
  60.         public TextView full_name;
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement