android123 zhihuibeijing 新聞中心-新聞 頁簽 ViewPagerIndicator實現

來源:互聯網
上載者:User

標籤:

## ViewPagerIndicator ##  使用匯入ViewPagerIndicator庫的方式相當於可以改源碼,打包編譯Eclips可以自動完成。ViewPager指標項目,在使用ViewPager的時候能夠指示ViewPager所在的位置,就像Google Play中切換的效果一樣,還能使用在應用初始化的介紹頁面1. 引入ViewPagerIndicator庫2. 編寫布局檔案         <com.viewpagerindicator.TabPageIndicator        android:id="@+id/indicator"        android:layout_width="fill_parent"        android:layout_height="wrap_content" />3. mIndicator.setViewPager(mViewPager);//將viewpager和mIndicator關聯起來,必須在viewpager設定完adapter後才能調用4. 重寫PagerAdapter方法,返回頁面標題        /**         * 重寫此方法,返回頁面標題,用於viewpagerIndicator的頁簽顯示         */        @Override        public CharSequence getPageTitle(int position) {            return mNewsTabData.get(position).title;        }5. 自訂樣式修改資訊清單檔: <activity    android:name=".MainActivity"    android:theme="@style/Theme.PageIndicatorDefaults" />然後修改Theme.PageIndicatorDefaults這個樣式檔案。

 

android123 zhihuibeijing 新聞中心-新聞 頁簽 ViewPagerIndicator實現

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.