示範 ViewPager,示範viewpager

來源:互聯網
上載者:User

示範 ViewPager,示範viewpager
本文內容

  • 環境
  • 項目結構
  • 示範 1:PagerTitleStrip
  • 示範 2:PagerTabStrip
  • 示範 3:ViewPager 和動態 Fragment
下載 Demo 環境
  • Windows 2008 R2 64 位元
  • Eclipse ADT V22.6.2,Android 4.4.2(API 19)
  • SAMSUNG GT-8618,Android OS 4.1.2
項目結構

圖 1 項目結構

圖 2 項目主介面 

示範 1:PagerTitleStrip

圖 3 示範 PagerTitleStrip 和點擊“微博”按鈕

示範 2:PagerTabStrip

圖 4 示範 PagerTabStrip

 

官方文檔,對 PagerTabStrip 和 PagerTitleStrip 描述是,“PagerTabStrip is an interactive indicator of the current, next, and previous pages of a ViewPager.” 而“PagerTitleStrip is a non-interactive indicator of the current, next, and previous pages of a ViewPager. ”

簡單來說,PagerTabStrip 和 PagerTitleStrip 都能實現滑動切換 Tab 頁,但是 PagerTabStrip 還通過點擊 Tab 的標籤實現 Tab 頁的切換;而 PagerTitleStrip 則不能。

示範 3:ViewPager 和動態 Fragment

圖 5 ViewPager 和動態 Fragment

 

FragmentStatePagerAdapter 和 FragmentPagerAdapter 的區別是,FragmentStatePagerAdapter 在當前只會存在前一個 Fragment,其他 Fragment 會銷毀,適合載入多資料;而FragmentPagerAdapter 是所有 Fragment 都存在,所以不太適合載入大量的資料 片什麼的,很容易記憶體溢出。

 

下載 Demo

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.