【问题标题】:No adapter attached; skipping layout in android未连接适配器;在android中跳过布局
【发布时间】:2021-07-06 13:10:56
【问题描述】:

但正在记录错误消息:

15:25:53.476 E/RecyclerView:未连接适配器;跳过布局

15:25:53.655 E/RecyclerView:未连接适配器;跳过布局

【问题讨论】:

  • 请在此处添加您的代码
  • 你没有在recyclerview中添加适配器。所以,这就是你获得日志的原因。

标签: android


【解决方案1】:

此错误发生在 RecyclerView 尝试呈现自身但没有附加适配器时。这通常不是严重错误。

FIX:尝试在 onCreate / onViewCreated 中将空适配器附加到 RecyclerView(用于片段):

//declare list with items to display 
private final List<POJOItem> items = new ArrayList<>();

//declare adapter 
Recyclerview adapter = new RecyclerViewAdapter(items)
//attach adapter 
recyclerView.setAdapter(adapter);

即使 List/ArrayList 为空,您连接的适配器和错误也应该停止显示。 附加适配器后,您可以随时将数据添加到数组中

【讨论】:

  • 谢谢各位,您的回答帮我解决了我的问题,谢谢
猜你喜欢
  • 2021-05-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-08-20
  • 1970-01-01
  • 2015-04-15
  • 2021-04-24
  • 2020-03-12
相关资源
最近更新 更多