Reputation: 3931
I have a ViewPager, which holds 3 Fragments. One of the fragments is a ScrollView, with several distinct sections (an About Me screen with photo uploading, details, settings sections).
I'm decoupling business logic with using MVVM, but still the Fragment is quite large (700 lines of code), as all of the sections need a great deal of UI logic (RecyclerViews, reactive fields, onActivityResult-related stuff).
If the Fragment was an Activity instead, I could just add all 3 sections as separate Fragments and manage communication with the Activity, but since it's a Fragment I'm not sure how to organise these nested sections so that they are not in one class but can still communicate with each other.
Upvotes: 2
Views: 85
Reputation: 2547
Yes. you can do nested fragments. I suggest split up your logic in multiple fragments to make it more modular and reusable.
This is the approach i would follow:
define layouts using multiple frameLayouts. In each framelayout, you can insert a fragment.
so something like: (this is not a real code but rather something to describe the potential solution)
Upvotes: 1