RecycleView遇到数据无法刷新问题

Android recycleView出现无法刷新的问题
一、在数据源已修改的情况下,使用了notifyDataSetChanged(),无法刷新数据,这是为何,将oncreateBindViewHolder()中的
View itemView = LayoutInflater.from(context).inflate(R.layout.rec_test, parent, false);
改为View itemView = LayoutInflater.from(context).inflate(R.layout.rec_test, null);此时可正常刷新数据,
二、如果布局是linearlayout布局,使用 View itemView = LayoutInflater.from(context).inflate(R.layout.rec_test, parent, false);对于item的布局,使用的是match_parent此时是显示可能导致布局显示不全,因为一个item都已经全布局,导致其他item不能正常显示,
在线性布局中修改需要是wrap_content,即可显示其它item布局
三、本质上View itemView = LayoutInflater.from(context).inflate(R.layout.rec_test, parent, false);表示不会直接添加到父布局中,需要addView才添加到父布局上,
而View itemView = LayoutInflater.from(context).inflate(R.layout.rec_test, null);等效于
View itemView = LayoutInflater.from(context).inflate(R.layout.rec_test, null,false);父布局为空,不会添加到父布局,此时item布局为match_parent时,可以正常显示全部item

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值