java.lang.Object | |
↳ | android.content.res.Resources.Theme |
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(AttributeSet, int[], int, int) APIs to retrieve XML attributes with style and theme information applied.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Place new attribute values into the theme.
| |||||||||||
Print contents of this theme out to the log.
| |||||||||||
Return a StyledAttributes holding the values defined by the style
resource resid which are listed in attrs.
| |||||||||||
Return a StyledAttributes holding the values defined by
Theme which are listed in attrs.
| |||||||||||
Return a StyledAttributes holding the attribute values in
set
that are listed in attrs.
| |||||||||||
Retrieve the value of an attribute in the Theme.
| |||||||||||
Set this theme to hold the same contents as the theme
other.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Is called before the object's memory is being reclaimed by the VM.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
|
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. |
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. |
Return a StyledAttributes holding the values defined by the style resource resid which are listed in attrs.
Be sure to call StyledAttributes.recycle() when you are done with the array.
resid | The desired style resource. |
---|---|
attrs | The desired attributes in the style. |
Resources.NotFoundException | Throws NotFoundException if the given ID does not exist. |
---|
Return a StyledAttributes holding the values defined by Theme which are listed in attrs.
Be sure to call StyledAttributes.recycle() when you are done with the array.
attrs | The desired attributes. |
---|
Resources.NotFoundException | Throws NotFoundException if the given ID does not exist. |
---|
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 StyledAttributes.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:
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. |
Retrieve the value of an attribute in the Theme. The contents of outValue are ultimately filled in by getValue(int, 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. |
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. |
---|
Is called before the object's memory is being reclaimed by the VM. This can only happen once the VM has detected, during a run of the garbage collector, that the object is no longer reachable by any thread of the running application.
The method can be used to free system resources or perform other cleanup
before the object is garbage collected. The default implementation of the
method is empty, which is also expected by the VM, but subclasses can
override finalize()
as required. Uncaught exceptions which are
thrown during the execution of this method cause it to terminate
immediately but are otherwise ignored.
Note that the VM does guarantee that finalize()
is called at most
once for any object, but it doesn't guarantee when (if at all) finalize()
will be called. For example, object B's finalize()
can delay the execution of object A's finalize()
method and
therefore it can delay the reclamation of A's memory. To be safe, use a
ReferenceQueue, because it provides more control
over the way the VM deals with references during garbage collection.
Throwable |
---|