Sdílet prostřednictvím


Resources.Theme.ObtainStyledAttributes Method

Definition

Overloads

ObtainStyledAttributes(Int32[])

Return a TypedArray holding the values defined by <var>Theme</var> which are listed in <var>attrs</var>.

ObtainStyledAttributes(Int32, Int32[])

Return a TypedArray holding the values defined by the style resource <var>resid</var> which are listed in <var>attrs</var>.

ObtainStyledAttributes(IAttributeSet, Int32[], Int32, Int32)

Return a TypedArray holding the attribute values in <var>set</var> that are listed in <var>attrs</var>.

ObtainStyledAttributes(Int32[])

Return a TypedArray holding the values defined by <var>Theme</var> which are listed in <var>attrs</var>.

[Android.Runtime.Register("obtainStyledAttributes", "([I)Landroid/content/res/TypedArray;", "")]
public Android.Content.Res.TypedArray ObtainStyledAttributes (int[] attrs);
[<Android.Runtime.Register("obtainStyledAttributes", "([I)Landroid/content/res/TypedArray;", "")>]
member this.ObtainStyledAttributes : int[] -> Android.Content.Res.TypedArray

Parameters

attrs
Int32[]

The desired attributes. These attribute IDs must be sorted in ascending order.

Returns

Returns a TypedArray holding an array of the attribute values. Be sure to call TypedArray#recycle() TypedArray.recycle() when done with it.

Attributes

Exceptions

Throws NotFoundException if the given ID does not exist.

Remarks

Return a TypedArray holding the values defined by <var>Theme</var> which are listed in <var>attrs</var>.

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

Java documentation for android.content.res.Resources.Theme.obtainStyledAttributes(int[]).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

See also

  • <xref:Android.Content.Res.Resources.ObtainAttributes(Android.Util.IAttributeSet%2c+System.Int32%5b%5d)>
  • <xref:Android.Content.Res.Resources.Theme.ObtainStyledAttributes(System.Int32%2c+System.Int32%5b%5d)>
  • <xref:Android.Content.Res.Resources.Theme.ObtainStyledAttributes(Android.Util.IAttributeSet%2c+System.Int32%5b%5d%2c+System.Int32%5b%5d%2c+System.Int32%5b%5d)>

Applies to

ObtainStyledAttributes(Int32, Int32[])

Return a TypedArray holding the values defined by the style resource <var>resid</var> which are listed in <var>attrs</var>.

[Android.Runtime.Register("obtainStyledAttributes", "(I[I)Landroid/content/res/TypedArray;", "")]
public Android.Content.Res.TypedArray ObtainStyledAttributes (int resId, int[] attrs);
[<Android.Runtime.Register("obtainStyledAttributes", "(I[I)Landroid/content/res/TypedArray;", "")>]
member this.ObtainStyledAttributes : int * int[] -> Android.Content.Res.TypedArray

Parameters

resId
Int32

The desired style resource.

attrs
Int32[]

The desired attributes in the style. These attribute IDs must be sorted in ascending order.

Returns

Returns a TypedArray holding an array of the attribute values. Be sure to call TypedArray#recycle() TypedArray.recycle() when done with it.

Attributes

Exceptions

Throws NotFoundException if the given ID does not exist.

Remarks

Return a TypedArray holding the values defined by the style resource <var>resid</var> which are listed in <var>attrs</var>.

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

Java documentation for android.content.res.Resources.Theme.obtainStyledAttributes(int, int[]).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

See also

  • <xref:Android.Content.Res.Resources.ObtainAttributes(Android.Util.IAttributeSet%2c+System.Int32%5b%5d)>
  • ObtainStyledAttributes(Int32[])
  • <xref:Android.Content.Res.Resources.Theme.ObtainStyledAttributes(Android.Util.IAttributeSet%2c+System.Int32%5b%5d%2c+System.Int32%5b%5d%2c+System.Int32%5b%5d)>

Applies to

ObtainStyledAttributes(IAttributeSet, Int32[], Int32, Int32)

Return a TypedArray holding the attribute values in <var>set</var> that are listed in <var>attrs</var>.

[Android.Runtime.Register("obtainStyledAttributes", "(Landroid/util/AttributeSet;[III)Landroid/content/res/TypedArray;", "")]
public Android.Content.Res.TypedArray ObtainStyledAttributes (Android.Util.IAttributeSet? set, int[] attrs, int defStyleAttr, int defStyleRes);
[<Android.Runtime.Register("obtainStyledAttributes", "(Landroid/util/AttributeSet;[III)Landroid/content/res/TypedArray;", "")>]
member this.ObtainStyledAttributes : Android.Util.IAttributeSet * int[] * int * int -> Android.Content.Res.TypedArray

Parameters

set
IAttributeSet

The base set of attribute values. May be null.

attrs
Int32[]

The desired attributes to be retrieved. These attribute IDs must be sorted in ascending order.

defStyleAttr
Int32

An attribute in the current theme that contains a reference to a style resource that supplies defaults values for the TypedArray. Can be 0 to not look for defaults.

defStyleRes
Int32

A resource identifier of a style resource that supplies default values for the TypedArray, used only if defStyleAttr is 0 or can not be found in the theme. Can be 0 to not look for defaults.

Returns

Returns a TypedArray holding an array of the attribute values. Be sure to call TypedArray#recycle() TypedArray.recycle() when done with it.

Attributes

Remarks

Return a TypedArray holding the attribute values in <var>set</var> that are listed in <var>attrs</var>. 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() 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:

<ol> <li> Any attribute values in the given AttributeSet. <li> The style resource specified in the AttributeSet (named "style"). <li> The default style specified by <var>defStyleAttr</var> and <var>defStyleRes</var> <li> The base values in this theme. </ol>

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 &lt;Button textColor="#ff000000"&gt;, then the button's text will <em>always</em> be black, regardless of what is specified in any of the styles.

Java documentation for android.content.res.Resources.Theme.obtainStyledAttributes(android.util.AttributeSet, int[], int, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

See also

  • <xref:Android.Content.Res.Resources.ObtainAttributes(Android.Util.IAttributeSet%2c+System.Int32%5b%5d)>
  • ObtainStyledAttributes(Int32[])
  • <xref:Android.Content.Res.Resources.Theme.ObtainStyledAttributes(System.Int32%2c+System.Int32%5b%5d)>

Applies to