Java tutorial
//package com.java2s; /** * Copyright (C) Azureus Software, Inc, All Rights Reserved. * <p/> * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ import java.util.*; import android.annotation.SuppressLint; public class Main { @SuppressLint("InlinedApi") public static String statesDebug(int[] states) { if (states == null) { return "null"; } if (states.length == 0) { return "[]"; } Map<Integer, String> map = new HashMap<>(); map.put(android.R.attr.state_above_anchor, "above_anchor"); map.put(android.R.attr.state_accelerated, "accelerated"); map.put(android.R.attr.state_activated, "activated"); map.put(android.R.attr.state_active, "active"); map.put(android.R.attr.state_checkable, "checkable"); map.put(android.R.attr.state_checked, "checked"); map.put(android.R.attr.state_drag_can_accept, "drag_can_accept"); map.put(android.R.attr.state_drag_hovered, "drag_hovered"); map.put(android.R.attr.state_empty, "empty"); map.put(android.R.attr.state_enabled, "enabled"); map.put(android.R.attr.state_expanded, "expanded"); map.put(android.R.attr.state_first, "first"); map.put(android.R.attr.state_focused, "focused"); map.put(android.R.attr.state_hovered, "hovered"); map.put(android.R.attr.state_last, "last"); map.put(android.R.attr.state_long_pressable, "long_pressable"); map.put(android.R.attr.state_middle, "middle"); map.put(android.R.attr.state_multiline, "multiline"); map.put(android.R.attr.state_pressed, "pressed"); map.put(android.R.attr.state_selected, "selected"); map.put(android.R.attr.state_single, "single"); map.put(android.R.attr.state_window_focused, "window_focused"); StringBuilder sb = new StringBuilder(); sb.append("["); for (int state : states) { if (sb.length() > 1) { sb.append(','); } String s = map.get(state); if (s == null) { sb.append(state); } else { sb.append(s); } } sb.append(']'); return sb.toString(); } }