Android: Generate random color on click?

android, colors, imageview

Solution

Random rnd = new Random();
paint.setARGB(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));

or

Random rnd = new Random(); 
int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));   
view.setBackgroundColor(color);

Though in your case it seems that you want to create a new drawable and assign it to your view. What is actually the drawable in your case? Is it an image, shape, fill...

Problem

I have an `ImageView`, in which I am programmaticly creating drawables and presenting them to the user. My goal is to click on said `ImageView` and change the drawable's color. How would I go about the random color changing bit? I am currently tinkering with `Random()`, `Color.argb()` and a few other things, but I can't seem to get it to work!

Original source