访问 GUI 元素的最佳方式
目前我使用这种方式(在课堂上更多次)来访问 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过 ID 查找视图需要调用并向下遍历视图层次结构 - 因此与变量访问相比,显然存在性能损失。
Finding view by ID requires a call and walking down view hierarchy - so clearly there is performance penalty as comparedto variable acces.