Is there a way to display fragments in TabHost?

I would like to show a different snippet in TabHost for each tab. But there seems to be no easy way to do this. TabHost can only accept A. Views or B. Efforts that trigger actions when the user selects a Tab.

Going with A means that I have to initialize each fragment and load them into a container. The views that are given by TabHost. But I want these fragments to be loaded only when necessary - when the user selects their tab.

Going with B means that I load fragments into separate actions for each tab. But I would like the fragment to be able to achieve the “original” parental activity, and not just some kind of shell. The activity that contains them in the contents of the tab.

Am I missing something? Is there a way to manage fragments using TabHost correctly?

+4
source share
1 answer

Some hits here:

In order for me to understand that the “link” of a fragment inside TabHost is not allowed, you need to create actions that include your fragments, and then call these actions from TabHost.

CHANGE Google's “official decision” and glorious animations .

+9
source

All Articles