Home | History | Annotate | Download | only in HorizontalPaging
      1 <?xml version="1.0" encoding="UTF-8"?>
      2 <!--
      3  Copyright 2013 The Android Open Source Project
      4 
      5  Licensed under the Apache License, Version 2.0 (the "License");
      6  you may not use this file except in compliance with the License.
      7  You may obtain a copy of the License at
      8 
      9      http://www.apache.org/licenses/LICENSE-2.0
     10 
     11  Unless required by applicable law or agreed to in writing, software
     12  distributed under the License is distributed on an "AS IS" BASIS,
     13  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  See the License for the specific language governing permissions and
     15  limitations under the License.
     16 -->
     17 <sample>
     18     <name>HorizontalPaging</name>
     19     <group>UI</group>
     20     <package>com.example.android.horizontalpaging</package>
     21 
     22     <!-- change minSdk if needed-->
     23     <minSdk>14</minSdk>
     24 
     25     <strings>
     26         <intro>
     27             <![CDATA[
     28             This sample demonstrates how to implement horizontal paging between fragments in
     29             applications that use ActionBar, using a ViewPager widget.
     30             ]]>
     31         </intro>
     32     </strings>
     33 
     34     <template src="base"/>
     35 
     36     <metadata>
     37         <status>DEPRECATED</status>
     38         <categories>UI</categories>
     39         <technologies>Android</technologies>
     40         <languages>Java</languages>
     41         <solutions>Mobile</solutions>
     42         <level>INTERMEDIATE</level>
     43         <icon>screenshots/icon-web.png</icon>
     44         <screenshots>
     45             <img>screenshots/1-tab1.png</img>
     46             <img>screenshots/2-tab2.png</img>
     47         </screenshots>
     48         <api_refs>
     49             <android>android.support.v4.view.ViewPager</android>
     50             <android>android.support.v4.app.FragmentPagerAdapter</android>
     51         </api_refs>
     52         <description>
     53 This sample shows how to implement tabs, using Fragments and a ViewPager.
     54         </description>
     55         <intro>
     56 This sample implements tabs using the deprecated [ActionBar.TabListener][1]. It uses [ViewPager][2] and
     57 [FragmentPagerAdapter][3] to handle swiping between tabs and displaying the selected tab content.
     58 
     59 
     60 1. Create an Activity that extends [FragmentActivity][4], with a [ViewPager][2] for its layout.
     61 2. Implement [ActionBar.TabListener][1] interface.
     62 3. Create a class that extends [FragmentPagerAdapter][3] and override its `getItem(int position)`,
     63 `getCount()` and `getPageTitle(int position)` methods.
     64 4. In the `onCreate(Bundle savedInstanceState)` method of your activity, set navigation mode to tabs for the
     65 ActionBar using `setNavigationMode(ActionBar.NAVIGATION_MODE_TABS)`. Note: This is DEPRECATED as of Android
     66 Lollipop.
     67 5. Set your custom [FragmentPagerAdapter][3] on your [ViewPager][2].
     68 6. Implement `setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener())` on your [ViewPager][2] to
     69 know the selected tab, so you can update your ActionBar with `setSelectedNavigationItem(position)`.
     70 
     71 [1]: http://developer.android.com/reference/android/support/v7/app/ActionBar.TabListener.html
     72 [2]: http://developer.android.com/reference/android/support/v4/view/ViewPager.html
     73 [3]: http://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter.html
     74 [4]: http://developer.android.com/reference/android/support/v4/app/FragmentActivity.html
     75         </intro>
     76     </metadata>
     77 
     78 </sample>
     79