【问题标题】:the best way to access gui elements访问 gui 元素的最佳方式
【发布时间】:2012-02-21 10:48:24
【问题描述】:

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

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

或者填充变量更好

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

我如何衡量性能?

谢谢!

【问题讨论】:

标签: android coding-style android-widget


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2010-10-07
    • 2014-06-15
    • 2020-12-16
    • 2014-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多