且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

尝试在 android 5.0 上使用 RecyclerView 时应用程序崩溃

更新时间:2023-01-24 23:20:35

这个问题通常在没有 LayoutManager 是为 RecyclerView.你可以这样做:

This issue usually occurs when no LayoutManager was provided for the RecyclerView. You can do it like so:

final LinearLayoutManager layoutManager = new LinearLayoutManager(context);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
recyclerView.setLayoutManager(layoutManager);