由于recyclerview适配器继承,用于舍入图像,但不获取getresources方法。 在BitmapFactory.decodeResource中找不到getresources
CODE--
public class ViewHolder extends RecyclerView.ViewHolder {
//ImageView image;
TextView imageName;
RelativeLayout parent_layout;
public ViewHolder(View itemView) {
super(itemView);
imageName=itemView.findViewById(R.id.image_name);
parent_layout=itemView.findViewById(R.id.parent_layout);
Bitmap bm = BitmapFactory.decodeResource(getresources,R.drawable.ic_svg_profile);
roundedImage = new RoundImage(bm);
ImageView imgvw = itemView.findViewById(R.id.image);
imgvw.setImageDrawable(roundedImage);
}
}
答案 0 :(得分:1)
尝试Bitmap bm = BitmapFactory.decodeResource(itemView.getContext().getResources(), R.drawable.ic_svg_profile);