正确显示文本信息,但我无法编辑和显示照片。 点击“编辑”按钮后,所有信息都显示为edittext,图像不显示imageview 请指导我
package com.rezam19975.myimage1;
class MyListAdapter扩展了BaseAdapter {
private Context context;
private List<InfoData> employees;
MyListAdapter(Context context, List<InfoData> employees){
this.context = context;
this.employees = employees;
}
@Override
public int getCount() {
return employees.size();
}
@Override
public Object getItem(int i) {
return employees.get(i);
}
@Override
public long getItemId(int i) {
return employees.get(i).getId();
}
@Override
public View getView(final int position, View view, ViewGroup viewGroup) {
View rowView = LayoutInflater.from(context).inflate(R.layout.list_item, viewGroup, false);
TextView txtName = (TextView) rowView.findViewById(R.id.txt_employee_name);
TextView txtPhone = (TextView) rowView.findViewById(R.id.txt_employee_phone);
TextView txtAddress = (TextView) rowView.findViewById(R.id.txt_employee_address);
Button btnEdit = (Button) rowView.findViewById(R.id.btn_edit);
Button btnDelete = (Button) rowView.findViewById(R.id.btn_delete);
ImageView imgview = (ImageView) rowView.findViewById(R.id.imgview);
txtName.setText(employees.get(position).getName());
txtPhone.setText(employees.get(position).getFamily());
txtAddress.setText(employees.get(position).getDescription());
// byte[] infoimage = ;
// Bitmap bitmap = BitmapFactory.decodeByteArray(infoimage, 0, infoimage.length);
// imgview.setImageBitmap(employees.get(position).getImage());
btnEdit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
((Manage) context).editEmployee(employees.get(position));
}
});
btnDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new MyDB(context).deleteEmployee(employees.get(position));
employees.remove(position);
notifyDataSetChanged();
}
});
return rowView;
}
}
代码java类:
public void editEmployee(InfoData infoData) {
findViewById(R.id.EdtID).setVisibility(View.VISIBLE);
btnSubmit.setOnClickListener(onEditEmployeeSubmit);
byte[] infoimage = Manage.image;
Bitmap bitmap = BitmapFactory.decodeByteArray(infoimage, 0, infoimage.length);
EdtNAME.setText(infoData.getName());
EdtFAMILY.setText(infoData.getFamily());
EdtDESCRIPTION.setText(infoData.getDescription());
ImgViewOrgs.setImageBitmap(bitmap);
seletcedEmployeeId = infoData.getId();
}
在列表视图中单击项目后显示除照片之外的所有信息