Android RecyclerView with Fragments

933 views Asked by At

I have a ViewPager with a FragmentPagerAdapter. My customer wants me to switch from ViewPager to list; a vertical list with all the fragments.

There can be a lot of fragments, so adding them all in a ScrollView is out of the question.

Can I somehow do this while still using a FragmentPagerAdapter? Adding fragments to, for example, the views in a recyclerview is not a good idea, I suppose?

What might be a good solution? I'm afraid I will have to stop using fragments for this altogether, but there is a lot of controller code in these fragments.

1

There are 1 answers

2
Anitha Manikandan On BEST ANSWER

Do not use any fragments on any recycling views like list view, recycler view etc. Fragments are attached to its container, in recycler view container will be changed frequently, as it is getting recycled. It will trouble later.

Better you can change the view pager to vertical scrolling view pager. You can refer link to make it vertical scrolling.