2012-02-21 144 views
-1

目前我用這種方式(在課堂上更多次)來訪問GUI元素訪問GUI元素

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

或者是它最好能填的最佳方式可變

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

和我如何衡量表現?

謝謝!

+0

可能重複[findViewById vs活動中的本地引用](http://stackoverflow.com/questions/3064437/findviewbyid-vs-local-reference-in-activity) – 2012-02-21 10:52:02

+0

另一個可能的重複:[Android效率 - 觀點](http://stackoverflow.com/questions/6430557/android-efficiency-views) – 2012-02-21 10:52:30

回答

0

通過標識查找視圖需要調用和向下走視圖層次結構 - 與變量訪問相比,顯然存在性能損失。