Reputation: 4250
I have a FragmentActivity
class with 2 tabs where content of these 2 tabs are created from 2 different Fragment classes. I found that when the FragmentActivity
onCreate()
is being called, it's creating both my tabs. Is it possible to create 2nd tab when I will click/swap to 2nd tab? I am using a FragmentPagerAdapter
.
Upvotes: 1
Views: 195
Reputation: 20553
If you are adding them dynamically, then they will be created when they are added. If they are added ih the xml then the FragmentActivity lifecycle is linked to the lifecycle of it's fragments. They will be created in accordance with the lifecycle of the parent fragment activity. You can choose to make them visible or invisible however.
Fragment and FragmentActivity callback relationship:
See the official docs for more details.
Upvotes: 1