Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.res.ColorStateList;
import android.graphics.Color;

public class Main {
    public static ColorStateList createColorStateList(int normal, int pressed) {
        return createColorStateList(normal, pressed, Color.GRAY);
    }

    public static ColorStateList createColorStateList(int normal, int pressed, int unable) {
        return createColorStateList(normal, pressed, pressed, pressed, unable);
    }

    public static ColorStateList createColorStateList(int normal, int pressed, int focused, int checked,
            int unable) {
        int[] colors = new int[] { pressed, focused, checked, normal, unable };
        int[][] states = new int[5][];
        states[0] = new int[] { android.R.attr.state_pressed, android.R.attr.state_enabled };
        states[1] = new int[] { android.R.attr.state_focused, android.R.attr.state_enabled };
        states[2] = new int[] { android.R.attr.state_checked, android.R.attr.state_enabled };
        states[3] = new int[] { android.R.attr.state_enabled };
        states[4] = new int[] {};
        return new ColorStateList(states, colors);
    }
}