You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
3.6 KiB
89 lines
3.6 KiB
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!--
|
|
Copyright 2017 The Android Open Source Project
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
-->
|
|
<sample>
|
|
<name>EffectiveNavigation</name>
|
|
<group>UI</group>
|
|
<package>com.example.android.effectivenavigation</package>
|
|
|
|
<!-- change minSdk if needed-->
|
|
<minSdk>9</minSdk>
|
|
|
|
<strings>
|
|
<intro>
|
|
<![CDATA[
|
|
This sample demonstrates how to create swipe views with tabs. Users can swipe
|
|
between tabs, or click on a tab title to jump to the section. Some tabs are
|
|
scrollable, meaning that users can scroll horizontally through the tab strip and
|
|
select a tab.
|
|
]]>
|
|
</intro>
|
|
<sample_action>Effective Navigation</sample_action>
|
|
</strings>
|
|
|
|
<metadata>
|
|
<status>PUBLISHED</status>
|
|
<categories>UI</categories>
|
|
<technologies>Android</technologies>
|
|
<languages>Java</languages>
|
|
<solutions>Mobile</solutions>
|
|
<level>BEGINNER</level>
|
|
<icon>screenshots/icon-web.png</icon>
|
|
<screenshots>
|
|
<img>screenshots/1-main.png</img>
|
|
<img>screenshots/2-collection.png</img>
|
|
</screenshots>
|
|
<api_refs>
|
|
<android>android.support.v4.view.ViewPager</android>
|
|
<android>android.support.design.widget.TabLayout</android>
|
|
<android>android.support.v4.app.NavUtils</android>
|
|
</api_refs>
|
|
<description>
|
|
<![CDATA[
|
|
This sample demonstrates how to create swipe views with tabs. Users can swipe
|
|
between tabs, or click on a tab title to jump to the section. Some tabs are
|
|
scrollable, meaning that users can scroll horizontally through the tab strip and
|
|
select a tab.
|
|
]]>
|
|
</description>
|
|
<intro>
|
|
<![CDATA[
|
|
This sample use combination of [ViewPager][1] and [TabLayout][2] to create swipe
|
|
views with tabs.
|
|
|
|
In order to use ViewPager, you first need to implement a PagerAdapter to feed
|
|
its content. In this sample, we use [FragmentPagerAdapter][3] and
|
|
[FragmentStatePagerAdapter][4]. FragmentPagerAdapter is useful when you have a
|
|
limited number of fixed pages. FragmentStatePagerAdapter can be used for
|
|
ViewPager with a lot of pages as it can save and restore state of Fragments
|
|
inside of it in a memory-efficient way.
|
|
|
|
Using TabLayout with ViewPager is simple. Just call the method
|
|
[setupWithViewPager(ViewPager)][5], and the TabLayout generates corresponding
|
|
tabs for the ViewPager. The titles are populated from [getPageTitle(int)][6]
|
|
method of your ViewPager adapter.
|
|
|
|
[1]: https://developer.android.com/reference/android/support/v4/view/ViewPager.html
|
|
[2]: https://developer.android.com/reference/android/support/design/widget/TabLayout.html
|
|
[3]: https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter.html
|
|
[4]: https://developer.android.com/reference/android/support/v4/app/FragmentStatePagerAdapter.html
|
|
[5]: https://developer.android.com/reference/android/support/design/widget/TabLayout.html#setupWithViewPager(android.support.v4.view.ViewPager)
|
|
[6]: https://developer.android.com/reference/android/support/v4/view/PagerAdapter.html#getPageTitle(int)
|
|
]]>
|
|
</intro>
|
|
</metadata>
|
|
</sample>
|