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
Setexactandallowwhileidle - Is Not Exact as of Developer Reference
Menu Items Are Not Showing on Action Bar
Displaying Yuv Image in Android
How to Populate Android Room Database Table on First Run
How to Be Notified on Wifi Network Status Change
Enabling General JavaScript in Webviewclient
Run-As Package 'A.B.C' Is Unknown - Galaxy S4 Jellybean or Android 4.3
How to Upload an Image in Parse Server Using Parse API in Android
Android Runtime Layout Tutorial
Android: Adding Static Header to the Top of a Listactivity
Placing a Textview on Top of Imageview in Android
How to Write Text Over a Picture in Android and Save It
Android How to Create Triangle and Rectangle Shape Programmatically
Play Rtsp Streaming in an Android Application
Android Ndk C++ Jni (No Implementation Found for Native...)