Glide-4.0.0 Missing Placeholder, Error, Glideapp and Does Not Resolve Its Method Placeholder,Error

Glide-4.0.0 Missing placeholder, error, GlideApp and does not resolve its method placeholder,error

Try using RequestOptions:

RequestOptions requestOptions = new RequestOptions();
requestOptions.placeholder(R.drawable.ic_placeholder);
requestOptions.error(R.drawable.ic_error);

Glide.with(context)
.setDefaultRequestOptions(requestOptions)
.load(url).into(holder.imageView);

EDIT

If .setDefaultRequestOptions(requestOptions) does not work, use .apply(requestOptions):

Glide.with(MainActivity.this)
.load(url)
.apply(requestOptions)
.into(imageview);
// or this
Glide.with(MainActivity.this)
.load(url)
.apply(new RequestOptions().placeholder(R.drawable.booked_circle).error(R.drawable.booked_circle))
.into(imageview);

// or this
Glide.with(MainActivity.this)
.load(url)
.apply(RequestOptions.placeholderOf(R.drawable.booked_circle).error(R.drawable.))
.into(imageview);

EDIT 2 Bonus

Here are some other changes in Glide-4

  • How to use requestOptions.circleCropTransform();
  • How to use Cross fades()
  • How to use GlideDrawableImageViewTarget in Glide-4
  • How to use GifDrawable as target parameter

Android - Glide .placeholder method not recognized

As shown in the Glide documentation:

Most options in Glide can be applied using the RequestOptions class
and the apply() method.

Use request options to apply (among others):

Placeholders
Transformations
Caching Strategies
Component specific options, like encode quality, or decode Bitmap configurations.

So, if you want to use placeholder, you have two options.

One of them is to do it this way:

Glide.with(context)
.load(items[position])
.apply(RequestOptions()
.placeholder(R.drawable.animated_loading_icon)
)
.into(holder.imageView)

And the other option would be to implement the Generated API

Placeholder/Error/Fallback in Glide v4

try this

RequestOptions requestOptions = new RequestOptions();
requestOptions.placeholder(R.mipmap.ic_launcher);
requestOptions.error(R.drawable.error_img);

Glide.with(this)
.setDefaultRequestOptions(requestOptions)
.load("")
.into(imageViewPlaceholder);

Placeholder/Error/Fallback in Glide v4

try this

RequestOptions requestOptions = new RequestOptions();
requestOptions.placeholder(R.mipmap.ic_launcher);
requestOptions.error(R.drawable.error_img);

Glide.with(this)
.setDefaultRequestOptions(requestOptions)
.load("")
.into(imageViewPlaceholder);

Glide 4.3.1: placeholder() method is not working

As a ten years android developer, I should tell you , if you use the first codes, Glide don't know which target the placeholder should place, you don't assign a imageView to the placeholder,
as we talked face to face, you should use ImageViewTarget instead of SimpleTarget, the constructor of ImageViewTarget has a param view, you can pass your imageView into there

Glide - Cannot resolve method override

In 4.3.1 you can use like this.

Glide.with(this)
.load(YOUR_URL)
.apply(new RequestOptions().override(dimenInPx, dimenInPx).placeholder(R.drawable.placeHolder).error(R.drawable.error_image))
.into(imageview);

Android Glide Cannot Resolve Method 'with' in GlideApp

According to the latest instructions you don't actually need to do ANY of the stuff from the link in the question. You just use "Glide" as normal and you don't have to use "GLideApp".

repositories {
google()
jcenter()
}

dependencies {
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
}

It also doesn't look like you need to setup a custom class or anything like that.

So I reverted to my old code:

Glide
.with(this)
.load(imageUrl)
.centerCrop()
.transition(withCrossFade())
.into(eventImageView);
}

Glide does not resolve its method

Seems like updated library has any issue. Add .apply(new RequestOptions() to continue with latest version.

CODE

Glide
.with(this)
.load(R.drawable.image_default_profile_picture)
.apply(new RequestOptions()
.placeholder(R.mipmap.ic_launcher)
.fitCenter())
.into(mUserImage);


Related Topics



Leave a reply



Submit