简体   繁体   English

E / RecyclerView:未连接适配器; 跳过布局Android RecycleView

[英]E/RecyclerView: No adapter attached; skipping layout Android RecycleView

I'm stuck in E/RecyclerView: No adapter attached; 我被卡在E / RecyclerView中:未连接适配器; Skipping layout error please help me to solve the error. 跳过布局错误,请帮助我解决错误。 I read most of related answers which are already present but error is still present. 我阅读了大多数已经存在的相关答案,但仍然存在错误。 Help me please give me some possible solutions. 帮帮我,请给我一些可能的解决方案。 Thanks in advance. 提前致谢。

One way to fix this issue is to attach an empty adapter to the RecyclerView : 解决此问题的一种方法是将一个空适配器附加到RecyclerView

void initializeRecyclerView() {
        recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
        recyclerView.setAdapter(new SampleAdapter(getCurrentActivity()));
        recyclerView.setLayoutManager(new LinearLayoutManager(getCurrentActivity()));
        recyclerView.setHasFixedSize(true);
    }

Call this method in onCreateView() or onCreate() methods. onCreateView()onCreate()方法中调用此方法。

Are you setting the layout manager for the RecyclerView ? 您是否正在为RecyclerView设置布局管理器?

LinearLayoutManager manager = new LinearLayoutManager(this);
manager.setOrientation(LinearLayoutManager.VERTICAL);
recyclerView.setLayoutManager(manager);
recyclerView.setAdapter(adapter);

Make sure you call these methods in the onCreate() for your activity. 确保在活动的onCreate()调用这些方法。

When the Views are attach they go through layout-phase. 附加视图后,它们将进入布局阶段。 Layout event is propagated to the children that are of type ViewGroup to start laying out their children too. 布局事件会传播到ViewGroup类型的子级,从而也开始布局其子级。 Which means that at that layout phase your RecyclerView attempts to layout views from the adapter. 这意味着在该布局阶段,您的RecyclerView尝试从适配器布局视图。 If the adapter returns item count 0 or it isn't set at all, the layout phase does nothing for your RecyclerView . 如果适配器返回的项目计数为0或根本没有设置,则布局阶段对RecyclerView Given this, RecyclerView will requestLayout() when the adapter is set and will start laying out views as soon as adapter has been provided. 鉴于此,设置适配器后, RecyclerViewrequestLayout() ,并在提供适配器后立即开始布局视图。

That message does not contribute towards your application performance and it isn't critical. 该消息不会影响您的应用程序性能,这也不重要。 You can safely ignore it. 您可以放心地忽略它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android:E / RecyclerView:未连接适配器; 跳过布局 - Android: E/RecyclerView: No adapter attached; skipping layout Android在recycleview片段选项卡布局消息中填充Firebase数据:E / RecyclerView:未连接适配器; 跳过布局 - Android populate firebase data in recycleview fragment tablayout message: E/RecyclerView: No adapter attached; skipping layout Recycleview RecyclerView:未连接适配器; 跳过布局 - Recycleview RecyclerView: No adapter attached; skipping layout RecyclerView Android 错误:E/RecyclerView:未连接适配器; 跳过布局 - RecyclerView Android Error: E/RecyclerView: No adapter attached; skipping layout Android RecycleView未附加适配器,跳过布局 - Android RecycleView No Adapter Attached, Skipping Layout E / RecyclerView:没有连接适配器; 跳过布局 - Android 9.0 Pie的问题 - E/RecyclerView: No adapter attached; skipping layout - problem with Android 9.0 Pie E/RecyclerView:没有附加适配器; 在 Android、kotlin 中跳过布局 - E/RecyclerView: No adapter attached; skipping layout in Android, kotlin E/RecyclerView:没有附加适配器; 跳过布局 Kotlin Android - E/RecyclerView: No adapter attached; skipping layout Kotlin Android Android studio E / RecyclerView:未连接适配器; 跳过布局 - Android studio E/RecyclerView: No adapter attached; skipping layout 错误 ANDROID STUDIO E/RecyclerView:未连接适配器; 跳过布局 - ERROR ANDROID STUDIO E/RecyclerView: No adapter attached; skipping layout
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM