[Blog Read] Android开发优化

Android开发优化之——对界面UI的优化(1)     http://blog.csdn.net/arui319/article/details/8549849

    利用系统的ID,图片,字符串,style,颜色
    记得对include的内容设置margin、padding等内容,需要重新写layout_width和layout_height

Android开发优化之——对界面UI的优化(2)  http://blog.csdn.net/arui319/article/details/8554816

    使用include标签重用layout,也有style那样的问题

Android开发优化之——对界面UI的优化(3)  http://blog.csdn.net/arui319/article/details/8561757

    使用ViewStub延迟加载,这个暂时还没有实际用过。

Android开发优化之——从代码角度进行优化    http://blog.csdn.net/arui319/article/details/8537588  这篇不错

    避免使用静态的资源,尽量使用Application的Context,Resource等

private static Resources mResources; 
@Override
protected void onCreate(Bundle state) {
    super.onCreate(state);
    if (mResources == null) {
        mResources = this.getResources();// 这里的resources引用了当前Activity,因此该Activity即使关闭了,也没法被回收
        mResources = this.getApplication().getResources(); // 这里的resources不会引用Activity,因此不会影响Activity的回收
    }
}
    即使关闭资源

Cursor cursor = null;
try{
    cursor = mContext.getContentResolver().query(uri,null,null,null,null);
    if (cursor != null) {
        cursor.moveToFirst();
        // 处理数据
    }
} catch (Exception e){
    e.printStatckTrace();
} finally {
    if (cursor != null){
        cursor.close();
    }
}
    listview的重用convertView和ViewHolder

    很多微调部分,这些没有深入来讲。

Android context(Application/Activity)与内存泄露   http://blog.csdn.net/ithomer/article/details/6891665

    专门讲context与内存泄露,Activity内对象的生命周期不要长于Activity。用Application的Context代替Activity的Context,避免内部静态类。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值