zoukankan      html  css  js  c++  java
  • android: adapter getView(position==0) was invoked many times.

      this is a big problem for me. i follow the solutions that i  searched from the internet: modify the listview layout and list-item layou file, 'wrap_content' to 'fill_parent'. but 'getView' function always was voked many time when the value of the 'position' is 0; i think it is maybe due to my complexed layout file.  so , i decide to give the a special way to load the data when 'position ' was 0; my solution like this:

    if(position==0){
                Bitmap bitmap = null;
                if(imageFetcher.mImageCache!=null){
                    bitmap = imageFetcher.mImageCache.get(entity.getPath());
                    if(bitmap!=null){
                        holder.imageView.setImageBitmap(bitmap);
                    }else {
                        bitmap = FileImageUtil.getImageLocal(entity.getPath(), 100, 100);
                        if(bitmap != null){
                            imageFetcher.mImageCache.put(entity.getPath(), bitmap);
                            holder.imageView.setImageBitmap(bitmap);
                        }else {
                            holder.imageView.setImageResource(R.drawable.image_broken);
                        }
                    }
                }
            }else {
                Log.d(TAG, "load position "+(position)+" ----- path "+entity.getPath()+" convertView "+convertView+" imageview " + holder.imageView);
                imageFetcher.loadBitmap(entity.getPath(), (position), 100, 100, holder.imageView);
            }

    it works fine.

  • 相关阅读:
    【jQuery插件】使用cropper实现简单的头像裁剪并上传
    Hibernate与 MyBatis的比较
    ES引擎原理介绍
    ES中的分词器研究
    服务转发Feign
    hytrix的python实现
    Consul的服务注册与发现-python版本
    setupTools工具新建项目
    docker系统学习
    NLP关键技术
  • 原文地址:https://www.cnblogs.com/slider/p/3210080.html
Copyright © 2011-2022 走看看