遍历AttributeSet枚举
|
我有以下代码:
private static boolean hasTargetStyle(AttributeSet attributes) {
final Enumeration<?> attributeNames = attributes.getAttributeNames();
while (attributeNames.hasMoreElements()) {
final Object attributeName = attributeNames.nextElement();
if (attributeName.equals(MY_STYLE_NAME)) {
return true;
}
}
return false;
}
现在,我认为这段代码将逐步遍历每个属性名称。但这只是给我其他所有属性名称(带有偶数索引的属性名称)。
这是怎么了?
没有找到相关结果
已邀请:
4 个回复
bab
没有索引。代码看起来不错。除非
返回错误实现的枚举,否则它应该起作用。
浩挎
佩疵瓦
的问题(尽管这只是一个接口,实际的实现可能会有错误)。您的实现对我来说很好。 其他想法:最初的“ 5”可能仅包含所有其他属性。尝试设置一个断点,并查看实际属性集的内部。
豹芜澈