如何设置行RecyclerView Adpater的图像

时间:2018-01-30 20:56:48

标签: android

我需要设置我的行RecyclerView的图像如何添加员工的图像我想将String转换为Bitmap并在imageView中显示图像

活动1

 String name = currentobject.getString("name_related");
                    String email = currentobject.getString("work_email");
                    String phone = currentobject.getString("work_phone");
                    String Img = currentobject.getString("image_small");
                    byte[] imageAsBytes = Base64.decode(Img.getBytes(), Base64.DEFAULT);
                    Bitmap decodedByte = BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length);

employee = new Employee(id,(String)deptArry.get(1),email,phone,decodingByte.toString(),name);                         Employees.add(雇员);

ClassAdapter如何添加员工的形象

   public void onBindViewHolder(EmployeeHolder holder, int position) {
            Employee employee=EmployeeList.get(position);
            holder.id.setText(employee.getId());
            holder.name.setText(employee.getName());
            holder.phone.setText(employee.getPhone());
            holder.Image.set????(employee.getImage());

    }

带有getter和setter的员工对象......

    private String id;
    private String name;
    private String phone;
    private String Image;

1 个答案:

答案 0 :(得分:0)

您的ViewHolder应该将ImageView作为其布局的一部分。现在您正在尝试将图像设置为“Image”,但“Image”是String类型。  将ImageView作为布局的一部分后,您只需调用:

imageView.setImageBitmap(decodedByte)