package hunnu.sj.raise_money.donate_record;

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

import java.util.ArrayList;

import hunnu.sj.raise_money.R;
import hunnu.sj.raise_money.record.Record;

public class DonateRecordAdapter extends BaseAdapter {
    private ArrayList<Record> recordlist;
    private Context context;
    public DonateRecordAdapter(Context context, ArrayList<Record> recordlist) {

        this.context = context;
        this.recordlist = recordlist;
    }
    @Override
    public int getCount() {
        return recordlist.size();
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public Object getItem(int position) {
        return recordlist.get(position);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = null;
        if(convertView != null){
            view  = convertView;
        }else{
            view = View.inflate(context, R.layout.donate_record_item,null);
        }
        Record record = recordlist.get(position);
        TextView record_vw = view.findViewById(R.id.record_descri);
        String descri = "您于"+record.getTime()+"给"+record.getStu_name()+"捐赠"+record.getDonatemon()+"元";
        record_vw.setText(descri);
        return view;
    }
}
