I have the following code:
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;
}
Now I would think this code would step through each of the attribute names. But it’s only giving me every other attribute name (the ones with even-numbered indices).
What’s going wrong here?
I don’t think it has an index – a
Setdoesn’t have index. And the code looks fine. Unless thegetAttributeNames()returns a wrongly-implementation enumeration, it should work.