【发布时间】:2018-05-24 05:19:10
【问题描述】:
【问题讨论】:
-
制作一个颜色数组,每次从数组中选择一个随机颜色。
【问题讨论】:
如果你正在使用滑翔,那么,
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);
}
});
【讨论】:
检查适配器中加载的数据是否为空。如果为空或“”,请为您的图像视图设置随机颜色。
这可能对您有所帮助 Generate and set random colors on text view background within Recycler View in Android
【讨论】: