Java tutorial
//package com.java2s; //License from project: Apache License import android.content.res.ColorStateList; import android.graphics.Color; public class Main { private static final String NAV_TEXT_COLOR_NORMAL = "#99A4B9"; private static final String NAV_TEXT_COLOR_CHECKED = "#0094D7"; public static ColorStateList getNavTextColorState() { return createColorStateList(Color.parseColor(NAV_TEXT_COLOR_CHECKED), Color.parseColor(NAV_TEXT_COLOR_NORMAL)); } private static ColorStateList createColorStateList(int checked, int normal) { int[] colors = new int[] { checked, normal }; int[][] states = new int[2][]; states[0] = new int[] { android.R.attr.state_checked, android.R.attr.state_enabled }; states[1] = new int[] {}; return new ColorStateList(states, colors); } private static ColorStateList createColorStateList(String b, int pressed, int normal) { int[] colors = new int[] { pressed, normal }; int[][] states = new int[2][]; states[0] = new int[] { android.R.attr.state_pressed, android.R.attr.state_enabled }; states[1] = new int[] {}; return new ColorStateList(states, colors); } }