我正在阅读有关的文档获取资源Id() https://developer.android.com/reference/android/content/res/TypedArray.html#getResourceId(int,%20int)方法。它说:
检索索引处属性的资源标识符。笔记
该属性资源在整个 TypedArray 对象时解析
被检索到。结果,该函数将返回资源
找到的最终资源值的标识符,不一定
属性指定的原始资源。
So
检索索引处属性的资源标识符。
请注意,属性资源在整体 TypedArray 时已解析
对象被检索。
-
但是第3段是什么意思呢? 为什么它可以返回 不一定是原始资源 ID?
结果,该函数将返回该资源的标识符
找到的最终资源值,不一定是原始资源值
由属性指定的资源。
来自文档 https://developer.android.com/reference/android/content/res/Resources.Theme.html#obtainStyledAttributes(android.util.AttributeSet,%20int%5B%5D,%20int,%20int):
TypedArray obtainStyledAttributes (AttributeSet set,
int[] attrs,
int defStyleAttr,
int defStyleRes)
....
当确定特定属性的最终值时,有
四个起作用的输入:
- 给定 AttributeSet 中的任何属性值。
- AttributeSet 中指定的样式资源(名为“style”)。
- defStyleAttr 和 defStyleRes 指定的默认样式
- 该主题中的基本值。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)