recyclerview没有附加适配器;跳绳布局 [英] recyclerview No adapter attached; skipping layout

查看:763
本文介绍了recyclerview没有附加适配器;跳绳布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚刚实施Recyclerview在我的code,取代列表视图。

just implemented Recyclerview in my code, replacing Listview.

一切工作正常。的对象被显示。

everything works fine. The objects are displayed.

但logcat的说

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

15:25:53.476 E/RecyclerView﹕ No adapter attached; skipping layout

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

15:25:53.655 E/RecyclerView﹕ No adapter attached; skipping layout

为code

ArtistArrayAdapter adapter = new ArtistArrayAdapter(this, artists);
recyclerView = (RecyclerView) findViewById(R.id.cardList);
recyclerView.setHasFixedSize(true);
recyclerView.setAdapter(adapter);``
recyclerView.setLayoutManager(new LinearLayoutManager(this));

你可以看到我重视的recycleview适配器。 那就是为什么我不断收到这个错误?

as you can see I have attached an adapter for recycleview. so why do i keep getting this error?

我已经阅读相关的同样的问题,其他的问题,但没有任何帮助。

i have read other questions related to same problem but none helps.

推荐答案

你能确保你在呼唤从主线程这些语句(例如onCreate方法里面)。 当我称之为从延迟方法相同的语句。在我的情况下,ResultCallback,我得到了同样的信息。

Can you make sure that you are calling these statements from the "main" thread (for example inside the onCreate method). As soon as I call the same statements from a "delayed" method. In my case a ResultCallback, I get the same message.

在我的片段,从里面ResultCallback方法调用低于code产生了同样的信息。移动code到onConnected方法中我的应用程序后,该消息已经走了......

In my fragment, calling the code below from inside a ResultCallback method produces the same message. After moving the code to the onConnected method within my app, the message was gone...

LinearLayoutManager llm = new LinearLayoutManager(this);
llm.setOrientation(LinearLayoutManager.VERTICAL);
list.setLayoutManager(llm);
list.setAdapter( adapter );

这篇关于recyclerview没有附加适配器;跳绳布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆