Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. import android.os.Bundle;
  2. import android.support.design.widget.TabLayout;
  3. import android.support.v4.app.Fragment;
  4. import android.support.v4.app.FragmentTabHost;
  5. import android.support.v4.view.ViewPager;
  6. import android.support.v7.widget.Toolbar;
  7. import android.view.LayoutInflater;
  8. import android.view.View;
  9. import android.view.ViewGroup;
  10.  
  11. public class AutoFragment extends Fragment{
  12. private FragmentTabHost mTabHost;
  13.  
  14. @Override
  15. public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
  16. mTabHost = new FragmentTabHost(getActivity());
  17. mTabHost.setup(getActivity(), getChildFragmentManager(), R.layout.fragment_auto);
  18. mTabHost.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"),
  19. JobFragment.class, null);
  20. mTabHost.addTab(mTabHost.newTabSpec("contacts").setIndicator("Contacts"),
  21. JobFragment.class, null);
  22. mTabHost.addTab(mTabHost.newTabSpec("custom").setIndicator("Custom"),
  23. JobFragment.class, null);
  24. mTabHost.addTab(mTabHost.newTabSpec("throttle").setIndicator("Throttle"),
  25. JobFragment.class, null);
  26.  
  27. return mTabHost;
  28. }
  29.  
  30. @Override
  31. public void onDestroyView() {
  32. super.onDestroyView();
  33. mTabHost = null;
  34. }
  35.  
  36. }
  37.  
  38. <LinearLayout
  39. android:layout_width="fill_parent"
  40. android:layout_height="fill_parent"
  41. android:orientation="vertical" >
  42.  
  43.  
  44. <TabWidget
  45. android:id="@android:id/tabs"
  46. android:layout_width="fill_parent"
  47. android:layout_height="wrap_content" />
  48.  
  49. <FrameLayout
  50. android:id="@android:id/tabcontent"
  51. android:layout_width="fill_parent"
  52. android:layout_height="fill_parent" >
  53. </FrameLayout>
  54. </LinearLayout>
  55.  
  56. </android.support.v4.app.FragmentTabHost>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement