【发布时间】:2011-09-01 19:45:35
【问题描述】:
我有以下代码:
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;
}
现在我认为这段代码会逐步遍历每个属性名称。但它只给了我所有其他属性名称(带有偶数索引的属性名称)。
这里出了什么问题?
【问题讨论】:
-
你的代码看起来不错;问题可能出在输入
AttributeSet。
标签: java enumeration