package jp.gihyo.mitoma.android.p031memberlist;

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 java.util.ArrayList;

public class CustomAdapter extends ArrayAdapter<MemberDTO> {
    private Context context;
    private int customLayout;
    private ArrayList<MemberDTO> memberList;
    public CustomAdapter(Context context,int customLayout,
                          ArrayList<MemberDTO> memberList){
        super(context,customLayout,memberList);
        this.context = context;
        this.customLayout = customLayout;
        this.memberList = memberList;
    }
    public View getView(int position, View shareView, ViewGroup parent){
        if (shareView == null) {
            LayoutInflater inflater = LayoutInflater.from(context);
            shareView = inflater.inflate(customLayout, parent, false);
        }

        // 行Viewを取得してデータをセット
        TextView tvMemberNo = shareView.findViewById(R.id.tvMemberNo);
        TextView tvMemberName = shareView.findViewById(R.id.tvMemberName);
        TextView tvPhone = shareView.findViewById(R.id.tvPhone);
        TextView tvEmail = shareView.findViewById(R.id.tvEmail);

        MemberDTO dto = memberList.get(position);
        tvMemberNo.setText(dto.memberNo);
        tvMemberName.setText(dto.memberName);
        tvPhone.setText(dto.phone);
        tvEmail.setText(dto.eMail);
        //戻り
        return shareView;
    }


}
