栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

E / RecyclerView:未连接适配器;跳过布局-制作待办事项列表应用程序时

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

E / RecyclerView:未连接适配器;跳过布局-制作待办事项列表应用程序时

正在跳过您的Recyclerview,因为在绘制布局时没有连接适配器。当前,您正在通过事件回调设置适配器,该事件回调在绘制布局并跳过Recyclerview之后仍将返回。您需要

setAdapter()

直接在“活动”中调用,
onCreate
然后更新适配器的数据,以确保
notifydatasetchanged
在事件回调中进行调用。

在活动的onCreate内部:

// Create an empty adapter since you don't have initial data// (You may need to alter the constructor of your Adapter class //  to keep it from trying to process empty/null data so it doesn't break)MyAdapter myAdapter = new MyAdapter(null);// Set the Recyclerview's Adapter so it isn't skipped on the layout passmyRecyclerView.setAdapter(myAdapter);

然后,在事件回调中:

// Update your Adapter with the new data using an update function you define in your AdaptermyAdapter.updateData(myNewData);// Notify the Adapter that the data has changedmyAdapter.notifyDataSetChanged();


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/483839.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号