访问 GUI 元素的最佳方式

发布于 2025-01-07 05:48:57 字数 295 浏览 1 评论 0原文

目前我使用这种方式(在课堂上更多次)来访问 gui 元素

((RadioButton)findViewById( R.id.STORAGE_RG_0 )).setEnabled(false);

,或者填充变量更好

RadioButton bla = ((RadioButton)findViewById( R.id.STORAGE_RG_0 ));
bla.setEnabled(false);

,我如何衡量性能?

谢谢 !

currently I use this way (more times in the class ) to access the gui elements

((RadioButton)findViewById( R.id.STORAGE_RG_0 )).setEnabled(false);

or is it better to fill a variable

RadioButton bla = ((RadioButton)findViewById( R.id.STORAGE_RG_0 ));
bla.setEnabled(false);

and how can i measure the performance ?

thanks !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无声情话 2025-01-14 05:48:57

通过 ID 查找视图需要调用并向下遍历视图层次结构 - 因此与变量访问相比,显然存在性能损失。

Finding view by ID requires a call and walking down view hierarchy - so clearly there is performance penalty as comparedto variable acces.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文