androidandroid-recyclerviewandroid-framelayout

Setting up a RecyclerView to FrameLayout issue in Android


I am trying to setup a RecyclerView which has the list items in a FrameLayout.

I have the following code:

// set up the RecyclerView
RecyclerView recyclerView = findViewById(R.id.recyclerView);

recyclerView.setLayoutManager(new FrameLayoutManager(this));

recyclerView.setAdapter(adapter);

The issue is that FrameLayoutManager is causing an error?!

How do I resolve this?


Solution

  • FrameLayoutManager is not a RecyclerView.LayoutManager; i.e. it doesn't extend from it. so, they are different types.

    As per documentation here are the valid RecyclerView LayoutManager classes:

    Which extend from the abstract class RecyclerView.LayoutManager