Back to project page Implementing-ActionBarSherlock-Side-Menu-Navigation-with-Fragment-Tabs-Tutorial.
The source code is released under:
Apache License
If you think the Android project Implementing-ActionBarSherlock-Side-Menu-Navigation-with-Fragment-Tabs-Tutorial listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.androidbegin.sidemenutabstutorial; //from ww w.ja va 2s.c om import java.lang.reflect.Field; import com.actionbarsherlock.app.SherlockFragment; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTabHost; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; public class Fragment2 extends SherlockFragment { // Declare Variable private FragmentTabHost mTabHost; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Create FragmentTabHost mTabHost = new FragmentTabHost(getSherlockActivity()); // Locate fragment2.xml to create FragmentTabHost mTabHost.setup(getSherlockActivity(), getChildFragmentManager(), R.layout.fragment2); // Create Tab 3 mTabHost.addTab(mTabHost.newTabSpec("tab3").setIndicator("Tab 3"), FragmentTab3.class, null); // Create Tab 4 mTabHost.addTab(mTabHost.newTabSpec("tab4").setIndicator("Tab 4"), FragmentTab4.class, null); return mTabHost; } // Detach FragmentTabHost @Override public void onDetach() { super.onDetach(); try { Field childFragmentManager = Fragment.class .getDeclaredField("mChildFragmentManager"); childFragmentManager.setAccessible(true); childFragmentManager.set(this, null); } catch (NoSuchFieldException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } // Remove FragmentTabHost @Override public void onDestroyView() { super.onDestroyView(); mTabHost = null; } }