android.util.AttributeSet |
已知间接子类
XmlResourceParser
|
属性的集合,通常在xml文档中出现,一般来说,你不会想直接去使用它,而是通过能够为你解释属性的Resources.Theme.obtainStyledAttributes()来使用它。特别的,Resources API 将转换引用资源(好比.xml文件中的"@string/my_label")为你希望的类型。如果,你直接使用AttributeSet,那么你就要手动的去检查你的资源应用(通过getAttributeResourceValue(int, int))并且如果需要的话你还要自己去查找资源。直接使用AttributeSet同样也会在检查属性时破坏Application的themes和styles.
这个接口也提供了一种通过使用XmlPullParser的Xml.asAttributeSet()的方法高效的从编译过的.xml文件检索数据的机制,通常情况下会返回一个通过XmlPullParser的接口实现,但它是在编译的XML资源结合时更加有用:
XmlPullParser parser = resources.getXml(myResouce); AttributeSet attributes = Xml.asAttributeSet(parser);
这种实现方法不像 XmlPullParser 的综合实现。在编译你的资源时,它高效实现了对appt已生成的预算信息检索的优化,例如getAttributeFloatValue(int, float)返回的是已经存储在你的编译资源中的浮点数而不是运行时的./xml文件中的原始字符串
这个借口还提供了包含在编译过的xml文件中在原始xml文件中不存在附加信息。例如getAttributeNameResource(int)返回的是与特定的XML相关联的资源标识符属性名称。
公有方法 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
abstract boolean | getAttributeBooleanValue(String namespace, String attribute, boolean defaultValue)
返回‘attribute’ 的Boolean值,默认
defaultValue
|
||||||||||
abstract boolean | getAttributeBooleanValue(int index, boolean defaultValue)
返回序列号为index的‘attribute’ 的Boolean值,默认defaultValue
|
||||||||||
abstract int | getAttributeCount()
返回属性集中的属性数
|
||||||||||
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.
|
Return the boolean value of 'attribute'.
namespace | 要检索的‘attribute’命名空间 |
---|---|
attribute | 要检索的‘attribute’ |
defaultValue | ‘attribute’没有找到的默认返回值 |
Return the boolean value of attribute at 'index'.
index | Index of the desired attribute, 0...count-1. |
---|---|
defaultValue | What to return if the attribute isn't found. |
Returns the number of attributes available in the set.
Return the float value of attribute at 'index'.
index | Index of the desired attribute, 0...count-1. |
---|---|
defaultValue | What to return if the attribute isn't found. |
Return the float value of 'attribute'.
namespace | Namespace of attribute to retrieve. |
---|---|
attribute | The attribute to retrieve. |
defaultValue | What to return if the attribute isn't found. |
Return the integer value of 'attribute'.
namespace | Namespace of attribute to retrieve. |
---|---|
attribute | The attribute to retrieve. |
defaultValue | What to return if the attribute isn't found. |
Return the integer value of attribute at 'index'.
index | Index of the desired attribute, 0...count-1. |
---|---|
defaultValue | What to return if the attribute isn't found. |
Return the index of the value of 'attribute' in the list 'options'.
namespace | Namespace of attribute to retrieve. |
---|---|
attribute | Name of attribute to retrieve. |
options | List of strings whose values we are checking against. |
defaultValue | Value returned if attribute doesn't exist or no match is found. |
Return the index of the value of attribute at 'index' in the list 'options'.
index | Index of the desired attribute, 0...count-1. |
---|---|
options | List of strings whose values we are checking against. |
defaultValue | Value returned if attribute doesn't exist or no match is found. |
Returns the name of the specified attribute.
index | Index of the desired attribute, 0...count-1. |
---|
Return the resource ID associated with the given attribute name. This will be the identifier for an attribute resource, which can be used by styles. Returns 0 if there is no resource associated with this attribute.
Note that this is different than getAttributeResourceValue(int, int)
in that it returns a resource identifier for the attribute name; the other method returns this attribute's value as a resource identifier.
index | Index of the desired attribute, 0...count-1. |
---|
Return the value of 'attribute' as a resource identifier.
Note that this is different than getAttributeNameResource(int)
in that it returns a the value contained in this attribute as a resource identifier (i.e., a value originally of the form "@package:type/resource"); the other method returns a resource identifier that identifies the name of the attribute.
namespace | Namespace of attribute to retrieve. |
---|---|
attribute | The attribute to retrieve. |
defaultValue | What to return if the attribute isn't found. |
Return the value of attribute at 'index' as a resource identifier.
Note that this is different than getAttributeNameResource(int)
in that it returns a the value contained in this attribute as a resource identifier (i.e., a value originally of the form "@package:type/resource"); the other method returns a resource identifier that identifies the name of the attribute.
index | Index of the desired attribute, 0...count-1. |
---|---|
defaultValue | What to return if the attribute isn't found. |
Return the integer value of attribute at 'index' that is formatted as an unsigned value. In particular, the formats 0xn...n and #n...n are handled.
index | Index of the desired attribute, 0...count-1. |
---|---|
defaultValue | What to return if the attribute isn't found. |
Return the boolean value of 'attribute' that is formatted as an unsigned value. In particular, the formats 0xn...n and #n...n are handled.
namespace | Namespace of attribute to retrieve. |
---|---|
attribute | The attribute to retrieve. |
defaultValue | What to return if the attribute isn't found. |
Returns the value of the specified attribute as a string representation.
index | Index of the desired attribute, 0...count-1. |
---|
Returns the value of the specified attribute as a string representation. The lookup is performed using the attribute name.
namespace | The namespace of the attribute to get the value from. |
---|---|
name | The name of the attribute to get the value from. |
Return the value of the "class" attribute or null if there is not one. Equivalent to getAttributeValue(null, "class").
Return the value of the "id" attribute or null if there is not one. Equivalent to getAttributeValue(null, "id").
Return the integer value of the "id" attribute or defaultValue if there is none. Equivalent to getAttributeResourceValue(null, "id", defaultValue);
defaultValue | What to return if the "id" attribute isn't found. |
---|
Returns a description of the current position of the attribute set. For instance, if the attribute set is loaded from an XML document, the position description could indicate the current line number.
Return the value of the "style" attribute or 0 if there is not one. Equivalent to getAttributeResourceValue(null, "style").