159******29HarmonyOS如何遍历页面中的控件?
sun以下代码仅供参考:
DependentLayout layout = (DependentLayout)findComponentById(ResourceTable.Id_layout);
for (int i = 0; i < layout.getChildCount(); i++) {
Component component = layout.getComponentAt(i);
if (component instanceof Button) {
Button btn = (Button)component;
btn.setBackground(new PixelMapElement(getResourceManager().getResource(ResourceTable.Media_icon)));
} else if (component instanceof Text) {
Text text = (Text)component;
text.setBackground(new ShapeElement(this,ResourceTable.Graphic_background_ability_main));
}
}
159******29好的,谢谢!2021-07-28 11:23 未知归属地
chaoxiaoshu
DirectionalLayout layout = (DirectionalLayout)findComponentById(ResourceTable.Id_layout); for (int i = 0; i < layout.getChildCount(); i++) { Component c = layout.getComponentAt(i); if (c instanceof Button) { Button btn = (Button)c; System.out.println(btn); } else if (c instanceof Text) { Text t = (Text)c; System.out.println(t); } }
159******29好的,谢谢!2021-07-28 11:22 未知归属地
五维空间幻影猫- 为了保障您的信息安全,请勿上传您的敏感个人信息(如您的密码等信息)和您的敏感资产信息(如关键源代码、签名私钥、调试安装包、业务日志等信息),且您需自行承担由此产生的信息泄露等安全风险。
- 如您发布的内容为转载内容,请注明内容来源。
我要发帖子
HarmonyOS 页面显示Web组件,其中包含多个输入框,默认获取的是第一个输入框,怎么获取后面的输入框? (API12+)
HarmonyOS 如何获取应用内各个页面的组件,页面包含UIExtension页面 (API12+)
HarmonyOS 页面中包含Web页面和TextArea组件,当软键盘弹起后会闪白,换掉Web组件就不复现了 (API12+)
HarmonyOS 页面滑动丢帧 (API12+)
HarmonyOS Pad分栏下显示H5页面UI异常 (API12+)
使用HMRouter路由框架设置页面标题栏的方法
HarmonyOS CEF页面,触屏点击无响应 (API12+)
HarmonyOS 如何使用 Toolbar 组件实现页面底部的工具栏? (API12+)




































苏公安网备 32011402010933号