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 ...
随机推荐
- fancybox iframe 刷新父页面(项目经验)
<script type="text/javascript"> $(document).ready(function() { $(".fancybox&quo ...
- UVA 12657 Boxes in a Line 双向链表
题目连接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=47066 利用链表换位置时间复杂度为1的优越性,同时也考虑到使用实际 ...
- git clone 错误ca-certificates.crt
git clone https://github.com/baoyiluo/selfblog.git Cloning into 'selfblog'... error: server certific ...
- Linux:文件类型和权限
一个目录要同时具有读权限和执行权限才可以打开,而一个目录要有写权限才允许在其中创建其它文件.
- 解析json实例
解析项目目录中的一个json文件,将之转化为List的一个方法. package com.miracles.p3.os.util; import com.miracles.p3.os.mode.Vid ...
- paip.提高稳定性---自动检测sleep mysql数据库死连接以及kill
paip.提高稳定性---自动检测sleep mysql数据库死连接以及kill 作者Attilax 艾龙, EMAIL:1466519819@qq.com 来源:attilax的专栏 地址:ht ...
- Python之线程池
版本一: #!/usr/bin/env python # -*- coding:utf-8 -*- import Queue import threading class ThreadPool(obj ...
- iOS10之后openURL:方法过期之后的替代方法及使用
目前苹果为iOS10开放了一个key:UIApplicationOpenURLOptionUniversalLinksOnly但亲测无效 目前使用的是这个key:UIApplicationOpenUR ...
- Windows Server 2016 桌面环境的自动配置脚本
除非学习要求,还是建议使用Windows 10 LTSB 2016或其他桌面系统. github:https://github.com/m2nlight/WindowsServerToWindowsD ...
- asp.net中调用命令行
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx. ...