gpt4 book ai didi

android - TypedArray 的 getResourceId 方法

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:36:47 28 4
gpt4 key购买 nike

我正在阅读关于 getResourceId() 的文档方法。它说:

Retrieves the resource identifier for the attribute at index. Note that attribute resource as resolved when the overall TypedArray object is retrieved. As a result, this function will return the resource identifier of the final resource value that was found, not necessarily the original resource that was specified by the attribute.

所以

  • 第一段清晰:

Retrieves the resource identifier for the attribute at index.

  • 第二个也很清楚:

Note that attribute resource as resolved when the overall TypedArray object is retrieved.

  • 但是第 3 段是什么意思? 为什么它可以返回 不一定是原始资源 ID

As a result, this function will return the resource identifier of the final resource value that was found, not necessarily the original resource that was specified by the attribute.

最佳答案

来自 documentation :

TypedArray obtainStyledAttributes (AttributeSet set, 
int[] attrs,
int defStyleAttr,
int defStyleRes)

....

When determining the final value of a particular attribute, there are four inputs that come into play:

  1. Any attribute values in the given AttributeSet.
  2. The style resource specified in the AttributeSet (named "style").
  3. The default style specified by defStyleAttr and defStyleRes
  4. The base values in this theme.

关于android - TypedArray 的 getResourceId 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37628461/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com