答案 0 :(得分:0)
如果你正在使用滑行,那么
Glide.with(context).load(url).into(new SimpleTarget<GlideDrawable>() {
@Override
public void onResourceReady(GlideDrawable resource,GlideAnimation<? super GlideDrawable> glideAnimation) {
}
@Override
public void onLoadFailed(Exception e, Drawable errorDrawable) {
super.onLoadFailed(e, errorDrawable);
Random rnd = new Random();
int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256),rnd.nextInt(256)); view.setBackgroundColor(color);
}
});
答案 1 :(得分:0)
检查适配器中加载的数据是否为空。如果它为null或&#34; &#34;,为图像视图设置随机颜色。
这可能会对你有所帮助 Generate and set random colors on text view background within Recycler View in Android