ResourceUtil.java 文件源码

java
阅读 38 收藏 0 点赞 0 评论 0

项目:ExoMedia 作者:
/**
 * Resolves the reference to an attribute, returning the root resource id.
 *
 * @param context The context to use when determining the root id
 * @param attr The attribute to resolve
 * @return The resource id pointing to the de-referenced attribute
 */
@AnyRes
public static int getResolvedResourceId(Context context, @AttrRes int attr) {
    TypedValue typedValue = new TypedValue();
    Resources.Theme theme = context.getTheme();
    theme.resolveAttribute(attr, typedValue, true);

    if (typedValue.type == TypedValue.TYPE_REFERENCE) {
        return typedValue.data;
    }

    return typedValue.resourceId;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号