必须是以下之一:RecyclerView.HORIZONTAL、RecyclerView.VERTICAL

Must be one of: RecyclerView.HORIZONTAL, RecyclerView.VERTICAL

升级到 AndroidX 后,当我设置 LayoutManager

tournamentRecyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));

问题 ID:WrongConstant。

检查 info:Ensures 当方法中的参数只允许一组特定的常量时,调用遵循这些规则

正如警告建议的那样,将 LinearLayoutManager.VERTICAL 更改为 RecyclerView.VERTICAL 它将完美地工作

示例:

tournamentRecyclerView.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, false));

您似乎在尝试将项目垂直放置在 RecyclerView 中,这是 LinearLayout

的默认行为

改变这个

tournamentRecyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));

至此

tournamentRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));