| | 6 | |
| | 7 | '''内存速度优化'''[[BR]] |
| | 8 | 原文参考:[http://developer.android.com/training/articles/perf-tips.html Performance Tips] |
| | 9 | 译文参考:[http://mobile.51cto.com/hot-276782.htm Android应用开发者指南:性能优化(1)] |
| | 10 | |
| | 11 | * 避免创建不必要的对象(废话) |
| | 12 | * 用静态代替虚方法,不需要访问某对象的字段,将方法设置为静态 |
| | 13 | * 避免内部的getters/setters,直接访问对象属性(能公开的属性设为Public) |
| | 14 | * 对常量使用static final修饰符(也是废话) |
| | 15 | * 使用改进的For循环语法,就是是用for(Foo:foo mArray){...}这样的写法 |
| | 16 | * 合理利用浮点数,能用整形用整形 |
| | 17 | |
| | 18 | '''布局优化[[BR]]''' |
| | 19 | |
| | 20 | (原文参考:[http://developer.android.com/training/improving-layouts/index.html ImprovingLayout Performance])[[BR]] |
| | 21 | |
| | 22 | * 尽量减少Android程序布局中View的层次,View层次越多,效率就越低 |
| | 23 | * 使用<include/>复用布局 |
| | 24 | * 使用ViewStub懒加载布局 ([http://mobile.51cto.com/abased-376576.htm Android布局技巧:使用ViewStub提高UI性能]) |
| | 25 | * 使用ViewHolder、Thread使ListView滚动更加流畅 |