IT. Expert System.

Android Reference



Class Resources.Theme

  • Enclosing class:

    public final class Resources.Theme
    extends Object
    This class holds the current attribute values for a particular theme. In other words, a Theme is a set of values for resource attributes; these are used in conjunction with TypedArray to resolve the final value for an attribute.

    The Theme's attributes come into play in two ways: (1) a styled attribute can explicit reference a value in the theme through the "?themeAttribute" syntax; (2) if no value has been defined for a particular styled attribute, as a last resort we will try to find that attribute's value in the Theme.

    You will normally use the obtainStyledAttributes(int[]) APIs to retrieve XML attributes with style and theme information applied.

    • Method Detail

      • applyStyle

        public void applyStyle(int resid,
                      boolean force)
        Place new attribute values into the theme. The style resource specified by resid will be retrieved from this Theme's resources, its values placed into the Theme object.

        The semantics of this function depends on the force argument: If false, only values that are not already defined in the theme will be copied from the system resource; otherwise, if any of the style's attributes are already defined in the theme, the current values in the theme will be overwritten.

        resid - The resource ID of a style resource from which to obtain attribute values.
        force - If true, values in the style resource will always be used in the theme; otherwise, they will only be used if not already defined in the theme.
      • setTo

        public void setTo(Resources.Theme other)
        Set this theme to hold the same contents as the theme other. If both of these themes are from the same Resources object, they will be identical after this function returns. If they are from different Resources, only the resources they have in common will be set in this theme.
        other - The existing Theme to copy from.
      • obtainStyledAttributes

        public TypedArray obtainStyledAttributes(AttributeSet set,
                                        int[] attrs,
                                        int defStyleAttr,
                                        int defStyleRes)
        Return a StyledAttributes holding the attribute values in set that are listed in attrs. In addition, if the given AttributeSet specifies a style class (through the "style" attribute), that style will be applied on top of the base attributes it defines.

        Be sure to call TypedArray.recycle() when you are done with the array.

        When determining the final value of a particular attribute, there are four inputs that come into play:

        1. Any attribute values in the given AttributeSet.
        2. The style resource specified in the AttributeSet (named "style").
        3. The default style specified by defStyleAttr and defStyleRes
        4. The base values in this theme.

        Each of these inputs is considered in-order, with the first listed taking precedence over the following ones. In other words, if in the AttributeSet you have supplied <Button textColor="#ff000000">, then the button's text will always be black, regardless of what is specified in any of the styles.

        set - The base set of attribute values. May be null.
        attrs - The desired attributes to be retrieved.
        defStyleAttr - An attribute in the current theme that contains a reference to a style resource that supplies defaults values for the StyledAttributes. Can be 0 to not look for defaults.
        defStyleRes - A resource identifier of a style resource that supplies default values for the StyledAttributes, used only if defStyleAttr is 0 or can not be found in the theme. Can be 0 to not look for defaults.
        Returns a TypedArray holding an array of the attribute values. Be sure to call TypedArray.recycle() when done with it.
        See Also:
        Resources.obtainAttributes(android.util.AttributeSet, int[]), obtainStyledAttributes(int[]), obtainStyledAttributes(int, int[])
      • resolveAttribute

        public boolean resolveAttribute(int resid,
                               TypedValue outValue,
                               boolean resolveRefs)
        Retrieve the value of an attribute in the Theme. The contents of outValue are ultimately filled in by Resources.getValue(int, android.util.TypedValue, boolean).
        resid - The resource identifier of the desired theme attribute.
        outValue - Filled in with the ultimate resource value supplied by the attribute.
        resolveRefs - If true, resource references will be walked; if false, outValue may be a TYPE_REFERENCE. In either case, it will never be a TYPE_ATTRIBUTE.
        boolean Returns true if the attribute was found and outValue is valid, else false.
      • dump

        public void dump(int priority,
                String tag,
                String prefix)
        Print contents of this theme out to the log. For debugging only.
        priority - The log priority to use.
        tag - The log tag to use.
        prefix - Text to prefix each line printed.
      • finalize

        protected void finalize()
                         throws Throwable
        Description copied from class: Object
        Invoked when the garbage collector has detected that this instance is no longer reachable. The default implementation does nothing, but this method can be overridden to free resources.

        Note that objects that override finalize are significantly more expensive than objects that don't. Finalizers may be run a long time after the object is no longer reachable, depending on memory pressure, so it's a bad idea to rely on them for cleanup. Note also that finalizers are run on a single VM-wide finalizer thread, so doing blocking work in a finalizer is a bad idea. A finalizer is usually only necessary for a class that has a native peer and needs to call a native method to destroy that peer. Even then, it's better to provide an explicit close method (and implement Closeable), and insist that callers manually dispose of instances. This works well for something like files, but less well for something like a BigInteger where typical calling code would have to deal with lots of temporaries. Unfortunately, code that creates lots of temporaries is the worst kind of code from the point of view of the single finalizer thread.

        If you must use finalizers, consider at least providing your own ReferenceQueue and having your own thread process that queue.

        Unlike constructors, finalizers are not automatically chained. You are responsible for calling super.finalize() yourself.

        Uncaught exceptions thrown by finalizers are ignored and do not terminate the finalizer thread. See Effective Java Item 7, "Avoid finalizers" for more.

        finalize in class Object


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: 77 / 158871962. Delta: 0.05273 с