w=10=sh n Glide vch

Placeholder/Error/Fallback in Glide v4

我目前使用的是最新版本的 Glide glide:4.0.0-RC1 并且无法找到占位符、错误、回退等方法 e.t.c.可能他们已经为它提供了替代方案,但我没有得到它。有人知道此版本中的替代方案吗?

试试这个

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

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

检查来自 here 的迁移详细信息。看起来他们有更多改进。

您有新的 class RequestOptions:

RequestOptions options = new RequestOptions()
    .centerCrop()
    .placeholder(R.drawable.placeholder)
    .error(R.drawable.error)
    .priority(Priority.HIGH);

然后,

Glide.with(fragment/activity)
    .load(url)
    .apply(options)
    .into(imageView);

要了解有关迁移详细信息的更多信息,您可以转到 here