return a random color for assignment to friend. - Android Graphics

Android examples for Graphics:Random Color

Description

return a random color for assignment to friend.

Demo Code


//package com.java2s;

import java.util.Random;
import android.graphics.Color;

public class Main {
    /**//ww w  .  j ava  2s .  c om
     * Helper function to return a random color for assignment to friend.
     * 
     * @return a randomly generated color
     */
    public static int generateRandomColor() {

        Random rand = new Random();
        int r = rand.nextInt(255);
        int g = rand.nextInt(255);
        int b = rand.nextInt(255);

        int randomColor = Color.argb(100, r, g, b);

        return randomColor;
    }
}

Related Tutorials