Android Guides | Samples

Android.Util.IAttributeSet

A collection of attributes, as found associated with a tag in an XML document.

See Also: IAttributeSet

Syntax

[Android.Runtime.Register("android/util/AttributeSet", "", "Android.Util.IAttributeSetInvoker")]
public interface IAttributeSet : IJavaObject, IDisposable

Remarks

A collection of attributes, as found associated with a tag in an XML document. Often you will not want to use this interface directly, instead passing it to NoType:android/content/res/Resources$Theme;Href=../../../reference/android/content/res/Resources.Theme.html#obtainStyledAttributes(android.util.AttributeSet, int[], int, int) which will take care of parsing the attributes for you. In particular, the Resources API will convert resource references (attribute values such as "@string/my_label" in the original XML) to the desired type for you; if you use AttributeSet directly then you will need to manually check for resource references (with IAttributeSet.GetAttributeResourceValue(Int32,Int32)) and do the resource lookup yourself if needed. Direct use of AttributeSet also prevents the application of themes and styles when retrieving attribute values.

This interface provides an efficient mechanism for retrieving data from compiled XML files, which can be retrieved for a particular XmlPullParser through Xml.AsAttributeSet(XmlReader). Normally this will return an implementation of the interface that works on top of a generic XmlPullParser, however it is more useful in conjunction with compiled XML resources:

The implementation returned here, unlike using the implementation on top of a generic XmlPullParser, is highly optimized by retrieving pre-computed information that was generated by aapt when compiling your resources. For example, the IAttributeSet.GetAttributeFloatValue(Int32,Single) method returns a floating point number previous stored in the compiled resource instead of parsing at runtime the string originally in the XML file.

This interface also provides additional information contained in the compiled XML resource that is not available in a normal XML file, such as IAttributeSet.GetAttributeNameResource(Int32) which returns the resource identifier associated with a particular XML attribute name.

[Android Documentation]

Requirements

Namespace: Android.Util
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1

The members of Android.Util.IAttributeSet are listed below.

Public Properties

[read-only]
AttributeCountInt32. Returns the number of attributes available in the set.
[read-only]
ClassAttributeString. Return the value of the "class" attribute or null if there is not one.
[read-only]
IdAttributeString. Return the value of the "id" attribute or null if there is not one.
[read-only]
PositionDescriptionString. Returns a description of the current position of the attribute set.
[read-only]
StyleAttributeInt32. Return the value of the "style" attribute or 0 if there is not one.

Public Methods

GetAttributeBooleanValue(Int32, Boolean) : Boolean
Return the boolean value of attribute at 'index'.
GetAttributeBooleanValue(String, String, Boolean) : Boolean
Return the boolean value of 'attribute'.
GetAttributeFloatValue(Int32, Single) : Single
Return the float value of attribute at 'index'.
GetAttributeFloatValue(String, String, Single) : Single
Return the float value of 'attribute'.
GetAttributeIntValue(Int32, Int32) : Int32
Return the integer value of attribute at 'index'.
GetAttributeIntValue(String, String, Int32) : Int32
Return the integer value of 'attribute'.
GetAttributeListValue(Int32, String[], Int32) : Int32
Return the index of the value of attribute at 'index' in the list 'options'.
GetAttributeListValue(String, String, String[], Int32) : Int32
Return the index of the value of 'attribute' in the list 'options'.
GetAttributeName(Int32) : String
Returns the name of the specified attribute.
GetAttributeNameResource(Int32) : Int32
Return the resource ID associated with the given attribute name.
GetAttributeResourceValue(Int32, Int32) : Int32
Return the value of attribute at 'index' as a resource identifier.
GetAttributeResourceValue(String, String, Int32) : Int32
Return the value of 'attribute' as a resource identifier.
GetAttributeUnsignedIntValue(Int32, Int32) : Int32
Return the integer value of attribute at 'index' that is formatted as an unsigned value.
GetAttributeUnsignedIntValue(String, String, Int32) : Int32
Return the boolean value of 'attribute' that is formatted as an unsigned value.
GetAttributeValue(Int32) : String
Returns the value of the specified attribute as a string representation.
GetAttributeValue(String, String) : String
Returns the value of the specified attribute as a string representation.
GetIdAttributeResourceValue(Int32) : Int32
Return the integer value of the "id" attribute or defaultValue if there is none.