Android AttributeSet API
Android AttributeSet API
Public interfaceAttributeSet
Android. util. AttributeSet |
Known indirect subclass XmlResourceParser |
Class Overview
A set of attributes is usually used in xml documents. Generally, you do not want to use it directly, but use it by Resources. Theme. obtainStyledAttributes () that can explain the attributes for you. In particular, the Resources API will convert the referenced Resources (like "@ string/my_label" in the. xml file) to your desired type. If you use AttributeSet directly, you need to manually check your resource application (through getAttributeResourceValue (int, int), and you need to find the resource yourself if necessary. Using AttributeSet directly will also damage the themes and styles of the Application during attribute check.
This interface also provides Xml by using XmlPullParser. the asAttributeSet () method is efficient from compiled. the xml file data retrieval mechanism usually returns an interface implemented through XmlPullParser, but it is more useful when compiling XML resources:
XmlPullParser parser = resources.getXml(myResouce); AttributeSet attributes = Xml.asAttributeSet(parser);
This implementation method is not like the integrated implementation of XmlPullParser. When compiling your resources, it efficiently optimizes the search for the budget information generated by the appt, such as getAttributeFloatValue (int, float) the returned result is a floating point number that has been stored in your compilation resources, rather than the runtime. /original string in xml file
This excuse also provides additional information contained in the compiled xml file that does not exist in the original xml file. For example, getAttributeNameResource (int) returns the Resource Identifier attribute name associated with the specific XML.
Overview
Public Method |
Abstract boolean |
GetAttributeBooleanValue (String namespace, String attribute, boolean defaultValue) Returns the Boolean value of 'attribute'. The default value is defaultValue. |
Abstract boolean |
GetAttributeBooleanValue (int index, boolean defaultValue) Returns the Boolean value of 'attribute' whose serial number is index. The default value is defaultValue. |
Abstract int |
GetAttributeCount () Returns the number of attributes in the attribute set. |
Abstract float |
GetAttributeFloatValue (int index, float defaultValue) Return the float value of attribute at 'index '. |
Abstract float |
GetAttributeFloatValue (String namespace, String attribute, float defaultValue) Return the float value of 'attribute '. |
Abstract int |
GetAttributeIntValue (String namespace, String attribute, int defaultValue) Return the integer value of 'attribute '. |
Abstract int |
GetAttributeIntValue (int index, int defaultValue) Return the integer value of attribute at 'index '. |
Abstract int |
GetAttributeListValue (String namespace, String attribute, String [] options, int defaultValue) Return the index of the value of 'attribute' in the list 'options '. |
Abstract int |
GetAttributeListValue (int index, String [] options, int defaultValue) Return the index of the value of attribute at 'index' in the list'options '. |
Abstract String |
GetAttributeName (int index) Returns the name of the specified attribute. |
Abstract int |
GetAttributeNameResource (int index) Return the resource ID associated with the given attribute name. |
Abstract int |
GetAttributeResourceValue (String namespace, String attribute, int defaultValue) Return the value of 'attribute' as a resource identifier. |
Abstract int |
GetAttributeResourceValue (int index, int defaultValue) Return the value of attribute at 'index' as a resource identifier. |
Abstract int |
GetAttributeUnsignedIntValue (int index, int defaultValue) Return the integer value of attribute at 'index' that is formatted as an unsigned value. |
Abstract int |
GetAttributeUnsignedIntValue (String namespace, String attribute, int defaultValue) Return the boolean value of 'attribute' that is formatted as an unsigned value. |
Abstract String |
GetAttributeValue (int index) Returns the value of the specified attribute as a string representation. |
Abstract String |
GetAttributeValue (String namespace, String name) Returns the value of the specified attribute as a string representation. |
Abstract String |
GetClassAttribute () Return the value of the "class" attribute or null if there is not one. |
Abstract String |
GetIdAttribute () Return the value of the "id" attribute or null if there is not one. |
Abstract int |
GetIdAttributeResourceValue (int defaultValue) Return the integer value of the "id" attribute or defaultValue if there is none. |
Abstract String |
GetPositionDescription () Returns a description of the current position of the attribute set. |
Abstract int |
GetStyleAttribute () Return the value of the "style" attribute or 0 if there is not one. |
Public method public abstract boolean getAttributeBooleanValue (String namespace, String attribute, boolean defaultValue) added to API Level 1
Return the boolean value of 'attribute '.
Parameters
Namespace |
The 'attribute' namespace to be retrieved |
Attribute |
The 'attribute' to be retrieved' |
DefaultValue |
Default return value not found in 'attribute' |
Return Value