Eldhopj
Eldhopj

Reputation: 3519

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

After upgrading into AndroidX i am getting this error "Must be one of: RecyclerView.HORIZONTAL, RecyclerView.VERTICAL" when i setting the LayoutManager

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

Issue id: WrongConstant.

Inspection info:Ensures that when parameter in a method only allows a specific set of constants, calls obey those rules

Upvotes: 0

Views: 2589

Answers (2)

Jasurbek
Jasurbek

Reputation: 2966

It seems you are trying to vertically place items in RecyclerView which is the default behavior for LinearLayout

Change this

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

to this

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

Upvotes: 3

Eldhopj
Eldhopj

Reputation: 3519

As the warning suggests change LinearLayoutManager.VERTICAL into RecyclerView.VERTICALit will work perfectly

for sample :

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

Upvotes: 5

Related Questions