getView(int position, View convertView, ViewGroup parent)

android开发

向上滑动 ListView ,item1 视图被滑出屏幕, item1视图被 回收到 Recycler( View 缓冲池) 中,如要显示 item8视图,先从缓存池中取出item1视图,更新 item8 需要显示的数据,变成了item8视图,把它放到ViewGroup中,ListView要的时候取出来。

ListView 的缓冲机制:需要时才显示,显示完就被会收到缓存。

在这里插入图片描述

public View getView(int position, View convertView, ViewGroup parent)

position:
The position of the item within the adapter’s data set of the item whose view we want.
显示屏中,要出现的一行搜索结果(一个item.xml形成的视图),其在搜索结果中的位置

convertView:
The old view(item的,每一行的视图) to reuse, if possible. Note: You should check that this view is non-null and of an appropriate type before using. If it is not possible to convert this view to display the correct data, this method can create a new view.
随着滑动,屏幕中消失的一行被回收到了缓存, 将其(convertVeiw)取出,在其视图中,更改控件信息(把将要显示的那一行的控件信息填进去),形成了新的即将在ListView中出现的item视图。
如果缓存中没有,要新建视图 convertView = myInflater.inflate(R.layout.item, null);//布局实例化

parent:
The parent that this view will eventually be attached to return A View corresponding to the data at the specified position.
每个item的视图,被放在了parent中,listeview要显示新出现的一行的视图时,把其取出来(把item1视图更改为item8视图后,也把它放到parent)

  • 12
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值