我正在尝试刷新组合中的 clabel。然而,标签并不总是存在。我需要一种方法来检查复合 Material 中是否存在。我已经在复合 Material 上尝试了 getChildren
类,并且能够使用它来查找复合 Material 上的所有 CLabel
,但我无法解析它们.
这就是我目前所拥有的
Control[] childs = comp.getChildren();
for (int i = 0; i < childs.length; i++) {
if(childs[i].getClass().getSimpleName().equalsIgnoreCase("CLabel")){
}
}
最佳答案
为什么不使用 instanceof
然后施放它?
Control[] children = comp.getChildren();
for (int i = 0; i < children.length; i++)
{
if(children[i] instanceof CLabel)
{
CLabel label = (CLabel) children[i];
/* Do something with the label */
}
}
关于java - 如何在复合 Material 中查找标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13863808/