Create color For Keycode - Android Graphics

Android examples for Graphics:Create Color

Description

Create color For Keycode

Demo Code


//package com.java2s;
import android.content.Context;

public class Main {
    static int[] colors = { android.R.color.holo_orange_light,
            android.R.color.holo_blue_bright,
            android.R.color.holo_green_light, android.R.color.holo_purple,
            android.R.color.holo_red_light,
            android.R.color.holo_green_dark,
            android.R.color.holo_orange_dark,
            android.R.color.holo_blue_dark, android.R.color.holo_red_dark,
            android.R.color.holo_blue_dark,
            android.R.color.holo_green_dark, };

    public static int colorForKeycode(Context c, int keycode) {
        return c.getResources().getColor(colors[keycode % colors.length]);
    }//  w  w  w.  j av a2 s.co  m
}

Related Tutorials