android - How to display ViewPager title? -
hi have implement viewpager in app. here have load imageadapter extends pageradapter , see images viewpager.
now, want display viewpager title image counter.
layout.xml
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/gallery_detail_layout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@color/black" > <android.support.v4.view.viewpager android:id="@+id/view_pager" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/rel_ig" > </android.support.v4.view.viewpager> </relativelayout> please 1 give me information how want that!
first need add android.support.v4.view.pagertabstrip layout.xml file like:
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/gallery_detail_layout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@color/black" > <android.support.v4.view.viewpager android:id="@+id/view_pager" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/rel_ig" > <android.support.v4.view.pagertabstrip android:id="@+id/pts_main" android:layout_width="match_parent" android:layout_height="wrap_content" /> </android.support.v4.view.viewpager> </relativelayout> now, override charsequence getpagetitle(int position) method int adapter like:
public class imageadapter extends pageradapter { ............ @override public charsequence getpagetitle(int position) { return (position + 1); } ........... } and implement pagertabstrip like: can customized pagertabstrip options
pagertabstrip strip = (pagertabstrip)view.findviewbyid(r.id.pts_main); strip.setdrawfullunderline(false); strip.settabindicatorcolor(color.dkgray); strip.setbackgroundcolor(color.gray); strip.setnonprimaryalpha(0.5f); strip.settextspacing(25); strip.settextsize(typedvalue.complex_unit_dip, 16);
Comments
Post a Comment