private Map<int[], Integer> getExistingColorStates(TextView view) { Map<int[], Integer> map = new LinkedHashMap<int[], Integer>(); ColorStateList textColors = view.getTextColors(); if (textColors != null) { try { Field specsField = textColors.getClass().getDeclaredField("mStateSpecs"); specsField.setAccessible(true); int[][] stateSpecs = (int[][]) specsField.get(textColors); Field colorsField = textColors.getClass().getDeclaredField("mColors"); colorsField.setAccessible(true); int[] colors = (int[]) colorsField.get(textColors); // These all should match if (stateSpecs != null && colors != null && stateSpecs.length == colors.length) { // load the map with the existing states for (int i = 0; i < stateSpecs.length; i++) { map.put(stateSpecs[i], colors[i]); } } } catch (Exception e) { PXLog.e(PXViewStyleAdapter.class.getSimpleName(), e, "Error getting the state set"); } finally { } } return map; }