I’ve seen many a tutorial for the standard FragmentTabsPager implementation, where a single Fragment is on each page. I’m attempting to combine the FragmentLayoutSupport example (ListFragment on left, details Fragment on right) with the pager example.
Here is the getItem() method in FragmentTabsPager from the v4 support library.
public Fragment getItem(int position) {
TabInfo info = mTabs.get(position);
return Fragment.instantiate(mContext, info.clss.getName(), info.args);
}
In order to support multiple Fragments per page (not nested, rather side by side), would it be a case of programmatically declaring a layout (e.g. LinearLayout) in my overridden version of this method, instantiating the two Fragments, and adding them as children, returning the LinearLayout? (In the case of a portrait orientation, returning the LinearLayout with only one Fragment.)
Is it sufficient to override this method alone, or is that a naive approach to the problem?
Thanks!
Don’t use the
FragmentPagerAdapter, create your own adapter that returns aView(in your case theLinearLayout).