[Android] Scrollable Navigation Tabs like Google Play

  • 0
* 1. [轉] Implementing Horizontal View Swiping Using ViewPager and FragmentPagerAdapter in Android


--

@ res/layout/
1. activity_main.xml
    + android.support.v4.view.ViewPager    // change between fragments
    + android.support.v4.view.PagerTabStrip    // show tab bar
2. fragment_layout.xml
    + custom view for each fragment layout (<textview> in example)

@ src
1. MyFragment.java
    // customize each fragment
    +  extends Fragment
    + onCreate(), onCreateView()
2. MyFragmentAdapter.java 
    + extends FragmentPagerAdapter
    + getItem(), getCount(), getPageTitle()
3. MainActivity.java
    + extends FragmentActivity
          >> extends ActionBarActivity 亦可, 因為 ActionBarActivity extends android.support.v4.app.FragmentActivity
    + onCreate()

/Android_Manifest.xml
    + intent-filter android:label
    > Android Intent Filter-判斷intent傳遞對象

--

* Fixed ActionBar Tab (need API Lv 11 up)
[Demo] Android Tab Layout with Swipeable Views

--
Reference
Tabs | Android Developer
Adding Navigation Tabs
    > ViewGroup + Fragment
    > ViewPager
Creating Swipe Views with Tabs - Scrollable Tabs
- [Github] Android-ViewPagerIndicator
- [Library] ActionBarSherlock

沒有留言 :

張貼留言