当前位置: 首页 > 知识库问答 >
问题:

无法解决 E/回收器视图: 未连接适配器;跳过布局错误 [重复]

毛越
2023-03-14

我有一个带有recycler视图的活动,当我单击其中的一个项目时,它会导致带有另一个recycler视图的活动。然而,它一直给我一个“E/RecyclerView:没有适配器连接;跳过布局”错误。

这是onCreate()方法:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getBundleData();
    setContentView(R.layout.activity_device_sensor_report);

    context = this;
    LiveDataInfo liveData = new LiveDataInfo(liveDataCat,liveDataNum);
    adapter = new AdapterLiveData(context, liveData);
    rv = (RecyclerView) findViewById(R.id.rv_liveData);
    layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL,false);
    rv.setLayoutManager(layoutManager);
    rv.setAdapter(adapter);


    //mqttSetup();
    drawGraph();


}

我看到了另一个类似于此的问题,即在运行其他线程之前连接适配器,但我不认为在这个活动中还有其他线程在运行。getBundleData()只执行以下操作:

Bundle extras = getIntent().getExtras();
    if (extras != null) {
        deviceID = extras.getString("DeviceID");
        temperature = extras.getParcelableArrayList("temperatureData");
        humidity = extras.getParcelableArrayList("humidityData");
        liveDataCat = extras.getParcelableArrayList("liveDataCat");
        liveDataNum = extras.getParcelableArrayList("liveDataNum");

    }

共有1个答案

金泉
2023-03-14

在logcat中,您经常可以看到以下错误。

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

不要

rv.setLayoutManager(layoutManager);
rv.setAdapter(adapter);

rv.setAdapter(adapter);
rv.setLayoutManager(layoutManager);
rv.setHasFixedSize(true); // optional
 类似资料:
  • 我收到以下错误:“RecyclerView:未连接适配器;跳过布局”,但我已连接适配器...我尝试了许多不同的方法,但我无法解决错误。 我正在使用Volley库获取数据。当我启动活动时,只有进度条可见,直到结束,我收到上面的Logcat消息。我在中添加了带有适配器的。你能帮我吗? 这是我的代码: 主活动 地震适配器 MainActivity.xml 地震法。xml

  • 它给了我“回收站视图:没有连接适配器;跳过布局“错误,但在我看来适配器已正确连接。请帮忙。 我正在移动我的方法,但它不起作用。我在这里寻找答案,但只有错误实现的适配器存在问题。我不知道这里出了什么问题。

  • 图像不显示。在一个SO例子中说要检查适配器中的计数,但我认为它是正确的。我在logcat中得到这个错误 这是代码主活动 这是我的适配器。

  • 我根据类似问题的答案修改了代码,但没有一个有效。我正在使用TabFragments和RecyclerViews。控制台显示错误“E/RecyclerView:No adapter attached;kipping layout”四次。 (当修改它也给了我错误java.lang.NullPointerException:试图调用虚方法'voidandroid.support.v7.widget.Re

  • 当应用程序启动时,我得到一个空白屏幕,当我检查日志时,我得到:E/回收人员视图:没有连接适配器;跳过布局错误 我不知道为什么?任何想法,它似乎没有附加回收器视图或添加任何数据,我附加了Main活动、DataAdapter和数据类。 主要活动 数据适配器 下面是我的数据类,将从中提取数据 我ncluded.java 收集器和设置器 这是jsonResponse类,在接口中引用 感谢任何帮助。

  • 一切正常,但数据没有显示。 但是当我签入“logcat”时,我发现了这个错误消息: 2021 10月20日11:29:37.387 7327-7327/com。实例myplay E/RecyclerView:未连接适配器;跳过布局 2021-10-20 11:29:37.388 7327-7327/com.example.myplayE/RecyClerView:未连接适配器;跳过布局 主要活动。