TypedArray.GetSourceResourceId(Int32, Int32) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回已解析指定属性的样式或布局的资源 ID,否则返回 defValue。
[Android.Runtime.Register("getSourceResourceId", "(II)I", "GetGetSourceResourceId_IIHandler", ApiSince=29)]
public virtual int GetSourceResourceId(int index, int defaultValue);
[<Android.Runtime.Register("getSourceResourceId", "(II)I", "GetGetSourceResourceId_IIHandler", ApiSince=29)>]
abstract member GetSourceResourceId : int * int -> int
override this.GetSourceResourceId : int * int -> int
参数
- index
- Int32
要检索其源样式的属性的索引。
- defaultValue
- Int32
如果未定义或未定义资源,则返回的值。
返回
样式资源 ID、布局资源 ID 或 defaultValue(如果未在样式或布局中解析)。
- 属性
注解
返回已解析指定属性的样式或布局的资源 ID,否则返回 defValue。
例如,如果你解析了两个属性,并且android:attribute2你正在从中夸大一个layout/my_layout.xmlandroid.view.View属性android:attribute1:
<View
style="@style/viewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:attribute1="foo"/>
且 @style/viewStyle 为:
<style android:name="viewStyle">
<item name="android:attribute2">bar<item/>
<style/>
然后解析 TypedArray 后,将具有返回其源资源 ID 的值,并且 R.layout.my_layout 返回其的 android:attribute1R.style.viewStyleandroid:attribute2源资源 ID。
Java文档android.content.res.TypedArray.getSourceResourceId(int, int)。
本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。