Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package info.androidhive.materialdesign.activity;
- import android.app.Activity;
- import android.content.Context;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.ArrayAdapter;
- import android.widget.ImageView;
- import android.widget.TextView;
- import android.widget.Toast;
- import info.androidhive.materialdesign.R;
- public class CustomAdapter extends ArrayAdapter<RowBean> {
- Context context;
- int nazwiskaImages;
- RowBean data[] = null;
- public CustomAdapter(Context context, int nazwiskaImages, RowBean[] data) {
- super(context, nazwiskaImages, data);
- this.nazwiskaImages = nazwiskaImages;
- this.context = context;
- this.data = data;
- }
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- View row = convertView;
- RowBeanHolder holder = null;
- if(row == null)
- {
- LayoutInflater inflater = ((Activity)context).getLayoutInflater();
- row = inflater.inflate(nazwiskaImages, parent, false);
- holder = new RowBeanHolder();
- holder.avatar = (ImageView)row.findViewById(R.id.avatar);
- holder.full_name = (TextView)row.findViewById(R.id.full_name);
- row.setTag(holder);
- }
- else
- {
- holder = (RowBeanHolder)row.getTag();
- }
- RowBean object = data[position];
- holder.full_name.setText(object.title);
- holder.avatar.setImageResource(object.icon);
- return row;
- }
- static class RowBeanHolder {
- public ImageView avatar;
- public TextView full_name;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement