Home | History | Annotate | Download | only in app
      1 /*
      2  * Copyright (C) 2012 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 package com.example.android.supportv4.app;
     17 
     18 //BEGIN_INCLUDE(complete)
     19 import com.example.android.supportv4.R;
     20 
     21 import android.os.Bundle;
     22 import android.support.v4.app.Fragment;
     23 import android.support.v4.app.FragmentTabHost;
     24 import android.view.LayoutInflater;
     25 import android.view.View;
     26 import android.view.ViewGroup;
     27 
     28 public class FragmentTabsFragmentSupport extends Fragment {
     29     private FragmentTabHost mTabHost;
     30 
     31     @Override
     32     public View onCreateView(LayoutInflater inflater, ViewGroup container,
     33             Bundle savedInstanceState) {
     34         mTabHost = new FragmentTabHost(getActivity());
     35         mTabHost.setup(getActivity(), getChildFragmentManager(), R.id.fragment1);
     36 
     37         mTabHost.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"),
     38                 FragmentStackSupport.CountingFragment.class, null);
     39         mTabHost.addTab(mTabHost.newTabSpec("contacts").setIndicator("Contacts"),
     40                 LoaderCursorSupport.CursorLoaderListFragment.class, null);
     41         mTabHost.addTab(mTabHost.newTabSpec("custom").setIndicator("Custom"),
     42                 LoaderCustomSupport.AppListFragment.class, null);
     43         mTabHost.addTab(mTabHost.newTabSpec("throttle").setIndicator("Throttle"),
     44                 LoaderThrottleSupport.ThrottledLoaderListFragment.class, null);
     45 
     46         return mTabHost;
     47     }
     48 
     49     @Override
     50     public void onDestroyView() {
     51         super.onDestroyView();
     52         mTabHost = null;
     53     }
     54 }
     55 //END_INCLUDE(complete)
     56