简体   繁体   中英

Can't load image with Glide/Fresco

This image can't be loaded with Glide/Fresco. Just empty image. Why?

This is my code:

Glide.with(context)            
 .load(ValidationHelper.getValidImageUrl(elements[position].author!!.image)
 .into(viewHolder.avatarImage)
            //viewHolder.avatarImage.setImageURI(ValidationHelper.getValidImageUrl(elements[position].author!!.image))

Please try below code :

Glide.with(this)  // Activity context
   .load(ValidationHelper.getValidImageUrl(elements[position].author!!.image) // Set URL
   .resize(100,100) // If you want to Resize the image then set image size
   .placeholder(getResources().getDrawable(R.drawable.ic_defuser)) // Default Image
   .error(getResources().getDrawable(R.drawable.ic_defuser))
   .into(viewHolder.avatarImage); // Imageview

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM