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.
android: adapter getView(position==0) was invoked many times.的更多相关文章
- Android Adapter的几个方法
1 ListView是在什么时候设置对Adapter的数据监听的? 在setAdapter(ListAdapter adapter)中,会先取消ListView中原来的mAdapter中的数据监听( ...
- Android ListView getView()方法重复调用导致position错位
问题现状:Android ListView getView()方法重复调用导致position错位 解决办法:把ListView布局文件的layout_height属性改为fill_parent或者m ...
- [转]Android Adapter以及getView()方法的理解
Android Adapter基本理解: 我的理解是: 1.一个有许多getter的类(就是getView(),getCount()....这些方法) 2.有多少个get方法?都是什么? 这些gett ...
- Android -- Adapter
体系 public interface Adapter----0层(表示继承体系中的层次) public interface ExpandableListAdapter---(无所谓层次因为没有其他 ...
- Android进阶(十四)Android Adapter详解
Android Adapter详解 Android是完全遵循MVC模式设计的框架,Activity是Controller,layout是View.因为layout五花八门,很多数据都不能直接绑定上去, ...
- Android Adapter推荐写法
package jason.fragmentdemo.adapter; import nqy.fragmentdemo.R; import nqy.fragmentdemo.model.Article ...
- Android Adapter基本理解
感谢大佬:https://blog.csdn.net/l799069596/article/details/47301711 Android Adapter基本理解: 我的理解是: 1.一个有许多ge ...
- Android Adapter的getViewTypeCount和getItemViewType
Adapter的getViewTypeCount和getItemViewType 不同的项目布局(item layout) 我们再举一个稍微复杂的例子,在上例的list中加入一些分隔线 你需要做这些: ...
- Android OpenGL ES 3.0 纹理应用
本文主要演示OpenGL ES 3.0 纹理演示.接口大部分和2.0没什么区别,脚本稍微有了点变化而已. 扩展GLSurfaceView package com.example.gles300; im ...
随机推荐
- Linux开启关闭redis
1.启动:redis-server(redis-server redis.conf) 2.登陆:redis-cli(redis-cli -p 6379) 3.关闭:redis-cli shutdown
- RHEL5.8使用yum安装xclock
使用xshell连接RHEL5.8服务器,敲入xclock命令想验证图形化安装条件,但是显示无此命令. [root@template ~]# xclock -bash: xclock: command ...
- Magicodes.WeiChat——WeChatOAuthTest(网页授权获取用户基本信息)
Demo访问地址:http://wechat.magicodes.net/app/AppDemo/WeChatOAuthTest?tenantId=1 关于公众号如何获取用户信息,请参考此文档:htt ...
- 关于QT的系统总结
编译环境与开发流程 开发QT有两种IDE可以使用,一种是使用 VS + Qt 的插件,另一种就是使用QtCreator工具.前一种是微软的工具,用的都比较多容易上手,缺点是信号槽的支持不太好,需要手写 ...
- 转:DataTable的Compute方法的应用
转自:http://www.cnblogs.com/hfliyi/archive/2013/01/08/2851944.html 项目中遇到计算平均值.标准偏差.平均值+标准偏差.平均值+2倍标准偏差 ...
- unity3D ——自带寻路Navmesh入门教程(一)(转)
转自:http://liweizhaolili.blog.163.com/blog/static/16230744201271161310135/ 说明:从今天开始,我阿赵打算写一些简单的教程,方便自 ...
- JETTY嵌入式Web容器的开发
JETTY嵌入式Web容器的开发 JETTY嵌入式Web容器体积小,启动速度快,性能好,免费开源,是一款很适合开发调试和简单演示的轻量级Web容器. 而且它的嵌入式的特点,使得开发者可以直接将容器的操 ...
- 在Debian下安装LAMP
准备工作: 1 sudo apt-get install build-essential 第一步:安装Apache 1 sudo apt-get install apache2 第二步:安装MySQL ...
- Javascript入门学习
编程之道,程序员不仅仅要精通一门语言,而是要多学习几门. 本学习之源出自柠檬学院http://www.bjlemon.com/,特此声明. 第一课1:javascript的主要特点解释型:不需要编译, ...
- 出现Bad command or the file name的原因
出现Bad command or file name的原因 中文释义:错误的命令或文件名 . 错误原因:不能识别输入的命令 . 方法:检查所输入的指令是否正确,包括拼写和大小写等情况.