Here is a method for getting a random color:
java
private static Random sRandom;
public static synchronized int randomColor() {
if (sRandom == null) {
sRandom = new Random();
}
return 0xff000000 + 256 * 256 * sRandom.nextInt(256) + 256 * sRandom.nextInt(256)
+ sRandom.nextInt(256);
}
Benefits:
- Get the integer representation which can be used with
java.awt.Colororandroid.graphics.Color - Keep a static reference to
Random.