1、Android新增的百分比布局
android.support.percent.PercentFrameLayout
在build.gradle下添加依赖包
compile 'com.android.support:percent:22.2.0'
2、LitePal开源数据库框架
3、关于ListView的优化
在Adapter的getView(int position,View convertView,ViewGroup parent)
方法中对于ListView的优化点主要是加载xml文件以及xml文件的组件加载处性能优化。
优化代码如下所示:
判断convertView是否为null,如果为null那么就通过LayoutInflater.from去加载布局文件,如果不为null则不用浪费性能重新加载xml文件,同样通过findViewWithTag或者findViewById的方式获取组件依旧会出现浪费性能的情况,所以这里通过myHolder.textView这样的方式获取组件就会提高ListView的加载性能,经过这两种方式就可以大大的提供ListView的性能了。
public View getView(final int position, View convertView, ViewGroup parent) {
        MyHolder myHolder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(SDKUtils.getResLayoutId(mContext, "user_item"), null);
            myHolder = new MyHolder();
            myHolder.textView = (TextView) convertView.findViewWithTag("account_textview");
            myHolder.imageView = (ImageView) convertView.findViewWithTag("account_icon");
            myHolder.delButton = (ImageView) convertView.findViewWithTag("account_del");
            convertView.setTag(myHolder);
            convertView.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT,
                    SDKUtils.getDimenValue(mContext, "user_item_height")));
            if (currentAccount.getText().toString().equals(list.get(position).getUserName())) {
                myHolder.imageView.setBackgroundResource(SDKUtils.getDrawableId(mContext, "sdk_select_account"));
            } else {
                myHolder.imageView.setBackgroundColor(Color.TRANSPARENT);
            }
        } else {
            myHolder = (MyHolder) convertView.getTag();
        }
        myHolder.textView.setText(list.get(position).getUserName());
        myHolder.delButton.setOnClickListener(new OnClickListener() {


            @Override
            public void onClick(View v) {
                SDKDBManager.getInstance().creatDB(mContext);
                SDKDBManager.getInstance().deleteAccount(list.get(position).getUserName());
                list.remove(position);
                notifyDataSetChanged();
                currentAccount.setText("");
            }
        });
        return convertView;
    }


    class MyHolder {
        public ImageView imageView;
        public TextView textView;
        public ImageView delButton;
    }

更多相关文章

  1. android:installLocation简析
  2. Android(安卓)slidingmenu详解 优化侧滑
  3. android:installLocation简析
  4. Android(安卓)性能参数获取
  5. Android性能优化:绘制优化
  6. android的ViewPager实现加载网络图片并自动轮播
  7. Android(安卓)应用程序快速启动的秘诀
  8. Android(安卓)移植到C#
  9. 利用BLCR加快android的启动过程

随机推荐

  1. Android(安卓)bug收集整理
  2. android学习网站
  3. android 百度地图轨迹回放
  4. ImageButton应用
  5. Gradle离线配置、.android、.AndroidStud
  6. ScrollView中添加ListView
  7. android获得mac和ip
  8. android自带Base64加密解密
  9. Android之短信发送器
  10. Linux 命令行更新指定版本 android sdk