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 插件扩展2
    jquery 插件扩展
    call apply bind
    bom object
    js oop 封装
    js oop 继承
    js页面之间传参2
    js弹出新窗口的6中方法
    display Tag
    js中extends方法
  • 原文地址:https://www.cnblogs.com/slider/p/3210080.html
Copyright © 2011-2022 走看看