因此,我试图将数据库中的图像加载到ViewHolader中的ImageView中。出现错误的方式:E / AndroidRuntime:致命异常:严重!我正在尝试用毕加索加载它,但它不允许我这样做。有什么正确的显示方式?
public void onBindViewHolder(@NonNull ViewHolder viewHolder, int i) {
viewHolder.nametext.setText(usersList.get(i).getBenutername());
viewHolder.orttext.setText(usersList.get(i).getOrt());
Picasso.get().load(usersList.get(i).getImage());
final String user_id = usersList.get(i).userId;
viewHolder.mView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(context, "User ID:"+user_id, Toast.LENGTH_SHORT).show();
}
});
nametext = (TextView) mView.findViewById(R.id.name_text);
image = (ImageView) mView.findViewById(R.id.image);
orttext = (TextView) mView.findViewById(R.id.ort_text);
}
尝试这种方式:
Picasso.get().load(usersList.get(i).getImage()).into(viewHolder.image);
// You need to pass your imageView which you have in your viewholder simple
您需要在要设置图像的in()方法中添加视图。