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, -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源中的resid> = 0x0100000是什么意思?全部内容,希望文章能够帮你解决android – AlertDialog源中的resid> = 0x0100000是什么意思?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)