package com.bonait.bnframework.modules.home.adapter;

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

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bonait.bnframework.R;
import com.bonait.bnframework.common.db.mode.BPA_PROCESS;
import com.bonait.bnframework.common.db.mode.BPA_PROCESSModel;
import com.bonait.bnframework.common.helper.I.MyClickListener;

import java.util.List;

/**
 * 工序表格
 */
public class processchid_adapter extends ArrayAdapter<BPA_PROCESSModel> {
    private List<BPA_PROCESSModel> datas;
    int resource1;
    public processchid_adapter(@NonNull Context context, int resource, @NonNull List<BPA_PROCESSModel> objects) {
        super(context, resource, objects);
        datas=objects;
        this.resource1=resource;
    }
    //每个子项被滚动到屏幕内的时候会被调用
    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        BPA_PROCESSModel lc = (BPA_PROCESSModel) getItem(position);//得到当前项选中item实例
        //为每一个子项加载设定的布局
        View view = LayoutInflater.from(getContext()).inflate(resource1, parent, false);
        //分别获取 image view 和 textview 的实例
        TextView name = view.findViewById(R.id.name);
        //TextView px = view.findViewById(R.id.px);
        //TextView lx = view.findViewById(R.id.lx);
        TextView jh = view.findViewById(R.id.jh);

        // 设置要显示的图片和文字
        name.setText(lc.name);
        jh.setText(lc.data);
        //px.setText(lc.sort+"");
//        switch (lc.datatype)
//        {
//            case 1:lx.setText("字符串");
//                break;
//            case 2:lx.setText("选项");
//                break;
//            default:lx.setText("数字");
//                break;
//        }
        return view;
    }
}