IT. Expert System.

Android Reference



Class ColorStateList

  • All Implemented Interfaces:

    public class ColorStateList
    extends Object
    implements Parcelable
    Lets you map View state sets to colors. ColorStateLists are created from XML resource files defined in the "color" subdirectory directory of an application's resource directory. The XML file contains a single "selector" element with a number of "item" elements inside. For example:
     <selector xmlns:android="">
       <item android:state_focused="true" android:color="@color/testcolor1"/>
       <item android:state_pressed="true" android:state_enabled="false" android:color="@color/testcolor2" />
       <item android:state_enabled="false" android:color="@color/testcolor3" />
       <item android:color="@color/testcolor5"/>
    This defines a set of state spec / color pairs where each state spec specifies a set of states that a view must either be in or not be in and the color specifies the color associated with that spec. The list of state specs will be processed in order of the items in the XML file. An item with no state spec is considered to match any set of states and is generally useful as a final item to be used as a default. Note that if you have such an item before any other items in the list then any subsequent items will end up being ignored.

    For more information, see the guide to Color State List Resource.

    • Constructor Detail

      • ColorStateList

        public ColorStateList(int[][] states,
                      int[] colors)
        Creates a ColorStateList that returns the specified mapping from states to colors.
    • Method Detail

      • valueOf

        public static ColorStateList valueOf(int color)
        Creates or retrieves a ColorStateList that always returns a single color.
      • withAlpha

        public ColorStateList withAlpha(int alpha)
        Creates a new ColorStateList that has the same states and colors as this one but where each color has the specified alpha value (0-255).
      • isStateful

        public boolean isStateful()
      • getColorForState

        public int getColorForState(int[] stateSet,
                           int defaultColor)
        Return the color associated with the given set of View states.
        stateSet - an array of View states
        defaultColor - the color to return if there's not state spec in this ColorStateList that matches the stateSet.
        the color associated with that set of states in this ColorStateList.
      • getDefaultColor

        public int getDefaultColor()
        Return the default color in this ColorStateList.
        the default color in this ColorStateList.
      • toString

        public String toString()
        Description copied from class: Object
        Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:
           getClass().getName() + '@' + Integer.toHexString(hashCode())

        See Writing a useful toString method if you intend implementing your own toString method.

        toString in class Object
        a printable representation of this object.
      • describeContents

        public int describeContents()
        Description copied from interface: Parcelable
        Describe the kinds of special objects contained in this Parcelable's marshalled representation.
        Specified by:
        describeContents in interface Parcelable
        a bitmask indicating the set of special object types marshalled by the Parcelable.


Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)





Java Script








Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 227 / 158869675. Delta: 0.04917 с