BaseAdapter的getView中经常出现position=0的情况
2014-09-04 12:18
295 查看
ListView的布局会影响getView的调用,当我的布局为
position=0调用了两次,而且我在geiview中没有生成足够数量的view时,convertView居然也返回了非空的值给我,正常是有view被回收时才会有非空的convertView返回
根据博客:http://blog.csdn.net/junjieking/article/details/7490602
我把布局改成了:
就正常了,开始时都是由geiView生成新的view,滚动列表有view被回收后converView传递缓存的view给geiView,但是还不知道这原因是为什么,有了解的朋友请告诉一下我,谢谢哈。
在这里找到比较好的解释:http://www.cnblogs.com/linjzong/p/3494090.html
可以看到如果高度或者宽度是 UNSPECIFIED的话,listview就会调用obtainView(0, mIsScrap),其中0就是传递给getView的position
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <ListView android:id="@+id/myList" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout>
position=0调用了两次,而且我在geiview中没有生成足够数量的view时,convertView居然也返回了非空的值给我,正常是有view被回收时才会有非空的convertView返回
根据博客:http://blog.csdn.net/junjieking/article/details/7490602
我把布局改成了:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="fill_parent"> <ListView android:id="@+id/myList" android:layout_width="match_parent" android:layout_height="match_parent"/> </LinearLayout>
就正常了,开始时都是由geiView生成新的view,滚动列表有view被回收后converView传递缓存的view给geiView,但是还不知道这原因是为什么,有了解的朋友请告诉一下我,谢谢哈。
在这里找到比较好的解释:http://www.cnblogs.com/linjzong/p/3494090.html
可以看到如果高度或者宽度是 UNSPECIFIED的话,listview就会调用obtainView(0, mIsScrap),其中0就是传递给getView的position
相关文章推荐
- android中ListView或GridView出现在adapter中的getView出现多次position为0的情况
- getView中经常出现position=0的情况
- Android 重写BaseAdapter碰到getView中convertView出现错误
- [置顶] (柯昌合深入研究Android SimpleAdapter BaseAdapter 的getView(int position, View convertView, ViewGroup pa
- (柯昌合深入研究Android SimpleAdapter BaseAdapter 的getView(int position, View convertView, ViewGroup parent)
- getView中经常出现position=0
- sql 在not in 子查询有null值情况下经常出现的陷阱
- 阿里巴巴 2015 实习笔试题 分布式系统中的RPC请求经常出现乱序的情况 写一个算法来将一个乱序的序列保序输出
- android baseadapter的getview调用两次
- Win8打开文件夹经常出现未响应情况的解决方法
- android BaseAdapter的getView的调用时机
- Android listview与adapter用法(BaseAdapter + getView)
- adapter的 getView 获取ListView的Position位置的ItemView
- BaseAdapter getView方法
- android: BaseAdapter的getview方法会多次重复调用
- 对于如何优化BaseAdapter中的getView方法说明,适配器的优化
- 阿里2015 实习笔试题笔记 分布式系统中的RPC请求经常出现乱序的情况
- Android-BaseAdapter中重写getview的心得以及发现convertView回收的机制
- getViewTypeCount 多个类型的Item显示BaseAdapter注意
- android-继承BaseAdapter--自定义适配器,getView执行多次的解决方法