package com.example.administrator.zhapp.adapter;

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.example.administrator.zhapp.R;
import com.example.administrator.zhapp.entity.LlrInfo;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.List;

/**
 * Created by Administrator on 2016/9/20.
 */
public class LlrAdapter extends BaseAdapter {

    private Context context;
    private List<LlrInfo.Llr> list;

    public LlrAdapter(Context context, List<LlrInfo.Llr> 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 i;
    }

    @Override
    public View getView(int i, View contentView, ViewGroup viewGroup) {

        ViewHolder holder;

        if (contentView == null) {
            holder = new ViewHolder();
            contentView = LayoutInflater.from(context).inflate(R.layout.llr_item, viewGroup,false);
            holder.tv_name = (TextView) contentView.findViewById(R.id.tv_name);
            contentView.setTag(holder);
            AutoUtils.autoSize(contentView);
        } else {
            holder = (ViewHolder) contentView.getTag();
        }

        holder.tv_name.setText(list.get(i).getUsername());

        return contentView;
    }

    class ViewHolder {
        TextView tv_name;
    }
}
