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.supportv13.app;
     17 
     18 import com.example.android.supportv13.R;
     19 
     20 import android.app.Fragment;
     21 import android.os.Bundle;
     22 import android.support.v13.app.FragmentTabHost;
     23 import android.view.LayoutInflater;
     24 import android.view.View;
     25 import android.view.ViewGroup;
     26 
     27 public class FragmentTabsFragment extends Fragment {
     28     private FragmentTabHost mTabHost;
     29 
     30     @Override
     31     public View onCreateView(LayoutInflater inflater, ViewGroup container,
     32             Bundle savedInstanceState) {
     33         mTabHost = new FragmentTabHost(getActivity());
     34         mTabHost.setup(getActivity(), getChildFragmentManager(), R.id.pager);
     35 
     36         mTabHost.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"),
     37                 CountingFragment.class, null);
     38         mTabHost.addTab(mTabHost.newTabSpec("array").setIndicator("Array"),
     39                 FragmentPagerSupport.ArrayListFragment.class, null);
     40         mTabHost.addTab(mTabHost.newTabSpec("cursor").setIndicator("Cursor"),
     41                 CursorFragment.class, null);
     42 
     43         return mTabHost;
     44     }
     45 
     46     @Override
     47     public void onDestroyView() {
     48         super.onDestroyView();
     49         mTabHost = null;
     50     }
     51 }
     52 //END_INCLUDE(complete)
     53