as indicated in the header, I am trying to have the tabhost that it contains in the fragment, where the contents of the tab are determined by the fragments. then,
i started with an example of FragmentsTab from Google. this shows how to use snippets as the contents of the tab, but TabHost
itself is still hosted in action. again, I need the tab host to be in the fragment.
I took the FragmentsTab
example and moved the code to onCreate()
and moved it to onCreateView()
in my Fragment
,
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View fragmentView = inflater.inflate(R.layout.detail_fragment, container); mTabHost = (TabHost) fragmentView.findViewById(android.R.id.tabhost); mTabHost.setup(); mTabManager = new TabManager(getActivity(), mTabHost, R.id.realtabcontent); // TODO: localize mTabManager.addTab(mTabHost.newTabSpec("info").setIndicator("File Info"), InfoFragment.class, null); return fragmentView; }
when I run, I get this exception,
05-25 14:42:27.272: E/AndroidRuntime(4701): Caused by: java.lang.IllegalStateException: Recursive entry to executePendingTransactions 05-25 14:42:27.272: E/AndroidRuntime(4701): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1343) 05-25 14:42:27.272: E/AndroidRuntime(4701): at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:429) 05-25 14:42:27.272: E/AndroidRuntime(4701): at com.zimbra.octopus.android.TabManager.onTabChanged(TabManager.java:116) 05-25 14:42:27.272: E/AndroidRuntime(4701): at android.widget.TabHost.invokeOnTabChangeListener(TabHost.java:359) 05-25 14:42:27.272: E/AndroidRuntime(4701): at android.widget.TabHost.setCurrentTab(TabHost.java:344) 05-25 14:42:27.272: E/AndroidRuntime(4701): at android.widget.TabHost.addTab(TabHost.java:216) 05-25 14:42:27.272: E/AndroidRuntime(4701): at com.zimbra.octopus.android.TabManager.addTab(TabManager.java:92) 05-25 14:42:27.272: E/AndroidRuntime(4701): at com.zimbra.octopus.android.DetailFragment.onCreateView(DetailFragment.java:46) 05-25 14:42:27.272: E/AndroidRuntime(4701): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:819) 05-25 14:42:27.272: E/AndroidRuntime(4701): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1053) 05-25 14:42:27.272: E/AndroidRuntime(4701): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:622) 05-25 14:42:27.272: E/AndroidRuntime(4701): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1371) 05-25 14:42:27.272: E/AndroidRuntime(4701): at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:429) 05-25 14:42:27.272: E/AndroidRuntime(4701): at com.zimbra.octopus.android.TabManager.onTabChanged(TabManager.java:116) 05-25 14:42:27.272: E/AndroidRuntime(4701): at android.widget.TabHost.invokeOnTabChangeListener(TabHost.java:359) 05-25 14:42:27.272: E/AndroidRuntime(4701): at android.widget.TabHost.setCurrentTab(TabHost.java:344) 05-25 14:42:27.272: E/AndroidRuntime(4701): at android.widget.TabHost.addTab(TabHost.java:216) 05-25 14:42:27.272: E/AndroidRuntime(4701): at com.zimbra.octopus.android.TabManager.addTab(TabManager.java:92) 05-25 14:42:27.272: E/AndroidRuntime(4701): at com.zimbra.octopus.android.DetailFragment.onCreateView(DetailFragment.java:46) 05-25 14:42:27.272: E/AndroidRuntime(4701): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:819) 05-25 14:42:27.272: E/AndroidRuntime(4701): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1032) 05-25 14:42:27.272: E/AndroidRuntime(4701): at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1111) 05-25 14:42:27.272: E/AndroidRuntime(4701): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:264) 05-25 14:42:27.272: E/AndroidRuntime(4701): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
looking at the trace, I see onCreateView()
for DetailFragment
(fragment accepting TabHost
), recursively. one way or another, a call to TabManager.addTab()
(again, see the FragmentsTab example) leads to a recursive call to DetailFragment.onCreateView()
.
what am I doing wrong? is it even possible? thanks.