|
|
@@ -20,24 +20,22 @@ import java.util.List; |
|
|
|
/** |
|
|
|
* 物料数据表格 |
|
|
|
*/ |
|
|
|
public class wl_adapter extends ArrayAdapter<BPA_MATERIAL> implements View.OnClickListener { |
|
|
|
public class wl_adapter extends ArrayAdapter<BPA_MATERIAL> { |
|
|
|
/** |
|
|
|
* 内部点击事件 |
|
|
|
*/ |
|
|
|
private MyClickListener mListener; |
|
|
|
/** |
|
|
|
* 物料数据 |
|
|
|
*/ |
|
|
|
public BPA_MATERIAL bpa_material; |
|
|
|
private List<BPA_MATERIAL> datas; |
|
|
|
public wl_adapter(@NonNull Context context, int resource, @NonNull List<BPA_MATERIAL> objects,MyClickListener listener) { |
|
|
|
super(context, resource, objects); |
|
|
|
mListener = listener; |
|
|
|
datas=objects; |
|
|
|
} |
|
|
|
//每个子项被滚动到屏幕内的时候会被调用 |
|
|
|
@NonNull |
|
|
|
@Override |
|
|
|
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { |
|
|
|
bpa_material = (BPA_MATERIAL) getItem(position);//得到当前项选中item实例 |
|
|
|
BPA_MATERIAL bpa_material = (BPA_MATERIAL) getItem(position);//得到当前项选中item实例 |
|
|
|
//为每一个子项加载设定的布局 |
|
|
|
View view = LayoutInflater.from(getContext()).inflate(R.layout.wl_item, parent, false); |
|
|
|
//分别获取 image view 和 textview 的实例 |
|
|
@@ -45,22 +43,18 @@ public class wl_adapter extends ArrayAdapter<BPA_MATERIAL> implements View.OnCl |
|
|
|
Button button = view.findViewById(R.id.button_item); |
|
|
|
// 设置要显示的图片和文字 |
|
|
|
name.setText(bpa_material.name); |
|
|
|
button.setOnClickListener(this); |
|
|
|
button.setOnClickListener(new View.OnClickListener() { |
|
|
|
@Override |
|
|
|
public void onClick(View view) { |
|
|
|
try |
|
|
|
{ |
|
|
|
mListener.clickListener(view,bpa_material); |
|
|
|
} catch (Exception e) |
|
|
|
{ |
|
|
|
T.show(view.getContext(),"删除物料出错:"+e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
return view; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 传出-->外部 |
|
|
|
* @param view |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void onClick(View view) { |
|
|
|
try |
|
|
|
{ |
|
|
|
mListener.clickListener(view,bpa_material); |
|
|
|
} catch (Exception e) |
|
|
|
{ |
|
|
|
T.show(view.getContext(),"删除物料出错:"+e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |