ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

android – AlertDialog源中的resid> = 0x0100000是什么意思?

2019-08-30 03:33:27  阅读:239  来源: 互联网

标签:android-alertdialog android alertdialog


AlertDialog源代码有以下方法:

static int resolveDialogTheme(Context context, int resid) {
    if (resid == THEME_TRADITIONAL) {
        return com.android.internal.R.style.Theme_Dialog_Alert;
    } else if (resid == THEME_HOLO_DARK) {
        return com.android.internal.R.style.Theme_Holo_Dialog_Alert;
    } else if (resid == THEME_HOLO_LIGHT) {
        return com.android.internal.R.style.Theme_Holo_Light_Dialog_Alert;
    } else if (resid == THEME_DEVICE_DEFAULT_DARK) {
        return com.android.internal.R.style.Theme_DeviceDefault_Dialog_Alert;
    } else if (resid == THEME_DEVICE_DEFAULT_LIGHT) {
        return com.android.internal.R.style.Theme_DeviceDefault_Light_Dialog_Alert;
    } else if (resid >= 0x01000000) {   // start of real resource IDs.
        return resid;
    } else {
        TypedValue outValue = new TypedValue();
        context.getTheme().resolveAttribute(com.android.internal.R.attr.alertDialogTheme,
                    outValue, true);
        return outValue.resourceId;
    }
}

0x01000000(我明白它是2 ^ 24)是什么意思?什么表达式resid> = 0x0100000检查?为什么渣油应该大于0x01000000到“真实资源ID的开始”?

解决方法:

Android资源ID的第24-31位是包ID.

包ID从1,0开始表示这不是基本包.

所以0x01000000是“真实资源ID的开始”.

看到上面的评论“uint32_t id;”在android frameworks source file中的“struct ResTable_package”.

“struct ResTable_package”定义如下.

/**
 * A collection of resource data types within a package.  Followed by
 * one or more ResTable_type and ResTable_typeSpec structures containing the
 * entry values for each resource type.
 */
struct ResTable_package
{
    struct ResChunk_header header;

    // If this is a base package, its ID.  Package IDs start
    // at 1 (corresponding to the value of the package bits in a
    // resource identifier).  0 means this is not a base package.
    uint32_t id;

    // Actual name of this package, \0-terminated.
    char16_t name[128];

    // Offset to a ResStringPool_header defining the resource
    // type symbol table.  If zero, this package is inheriting from
    // another base package (overriding specific values in it).
    uint32_t typeStrings;

    // Last index into typeStrings that is for public use by others.
    uint32_t lastPublicType;

    // Offset to a ResStringPool_header defining the resource
    // key symbol table.  If zero, this package is inheriting from
    // another base package (overriding specific values in it).
    uint32_t keyStrings;

    // Last index into keyStrings that is for public use by others.
    uint32_t lastPublicKey;
};

标签:android-alertdialog,android,alertdialog
来源: https://codeday.me/bug/20190830/1765791.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有