Shouldn't it be an id corresponding to a view that is inside the FragmentActivity's view hierarchy?
Not quite. If you look at the source code for the FragmentTabHost
class you'll see that the FragmentTabHost
will use the provided id only when the container, which will hold the content, doesn't already exist. This doesn't happen in that sample as the constructors of FragmentTabHost
call a private method which has the task of building a layout(including the above content container) file if the FragmentTabHost
doesn't contain a TabWidget
.
So in that sample the FragmentTabHost
doesn't contain a TabWidget
which triggers a layout to be built. Having this built layout means the id provided to the setup()
method is ignored. They might as well simply call mTabHost.setup(this, getSupportFragmentManager());
.