package com.qhclh.ytzh.work.Hatchery;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.qhclh.ytzh.R;

import java.util.List;

/**
 * Created by 青花瓷 on 2018/4/2.
 */

public class HatcheryAdapter extends BaseAdapter {
    private Context context;
    private List<HatcheryBean> list;

    public HatcheryAdapter(Context context, List<HatcheryBean> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return list.get(i).getId();
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        HatcheryBean message = list.get(i);
        if (view == null) {
            holder = new ViewHolder();
            view = LayoutInflater.from(context).inflate(R.layout.item_hatchery, viewGroup,false);
            holder.item_hatchery_name = view.findViewById(R.id.item_hatchery_name);

            view.setTag(holder);
        }else {
            holder = (ViewHolder) view.getTag();
        }

        holder.item_hatchery_name.setText(message.getName());
        return view;
    }

    private class ViewHolder {
        TextView item_hatchery_name;
    }
}
