正在跳过您的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();



