Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8970791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:47:35+00:00 2026-06-15T17:47:35+00:00

I am using http://viewpagerindicator.com/ library. I would like to create a TitlePageIndicator like the

  • 0

I am using http://viewpagerindicator.com/ library. I would like to create a TitlePageIndicator like the below image on Gmail app:

enter image description here

I exactly want to achieve the same thing where first title is ‘Newer’, last title is ‘Older’ and center title is ‘[page position] of [total pages]’. Is it possible to achieve this with the library I am using or should I modify it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:47:37+00:00Added an answer on June 15, 2026 at 5:47 pm

    I had the same issue. Solved like this with the help from Matthieu. Based this on the samples that come with the ViewPagerIndicator.

    Basically listening when the page change and change the adapter to give a different page title depending on the current position. The code given below simply works for me.

    If you have those samples working and you just replace those two files, then try this sample

    Changed the code for TestFragmentAdapter like this:

    class TestFragmentAdapter extends FragmentPagerAdapter implements IconPagerAdapter {
        protected static final String[] CONTENT = new String[] { "This", "Is", "stack", "overflow"  };
        protected static final int[] ICONS = new int[] {
            R.drawable.perm_group_calendar,
            R.drawable.perm_group_camera,
            R.drawable.perm_group_device_alarms,
            R.drawable.perm_group_location
    };
    
    private int mCount = CONTENT.length;
    
    // CHANGE START HERE
    private int current_position=0;
    
    public void set_current_position(int i) {
        current_position = i;
    }
    // CHANGE ENDS HERE
    
    public TestFragmentAdapter(FragmentManager fm) {
        super(fm);
    }
    
    @Override
    public Fragment getItem(int position) {
        return TestFragment.newInstance(CONTENT[position % CONTENT.length]);
    }
    
    @Override
    public int getCount() {
        return mCount;
    }
    
    @Override
    public CharSequence getPageTitle(int position) {
        // CHANGE START HERE
        if (position == current_position-1) {
            return "Previous";
        } else if (position == current_position+1) {
            return "Next";
        }
        // CHANGE ENDS HERE
        return TestFragmentAdapter.CONTENT[position % CONTENT.length];
    }
    
    @Override
    public int getIconResId(int index) {
      return ICONS[index % ICONS.length];
    }
    
    public void setCount(int count) {
        if (count > 0 && count <= 10) {
            mCount = count;
            notifyDataSetChanged();
        }
    }
    }
    

    the code for SampleTitlesDefault like this (added the OnPageChangeListener)

    public class SampleTitlesDefault extends BaseSampleActivity implements ViewPager.OnPageChangeListener {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.simple_titles);
    
        mAdapter = new TestFragmentAdapter(getSupportFragmentManager());
    
        mPager = (ViewPager)findViewById(R.id.pager);
        mPager.setAdapter(mAdapter);
    
        mIndicator = (TitlePageIndicator)findViewById(R.id.indicator);
        mIndicator.setViewPager(mPager);
        // CHANGE START HERE
        mIndicator.setOnPageChangeListener(this);
        // CHANGE ENDS HERE
    }
    
    // CHANGE START HERE
    @Override
    public void onPageScrolled(int i, float v, int i1) {
    }
    
    @Override
    public void onPageSelected(int i) {
        mPager = (ViewPager)findViewById(R.id.pager);
        ((TestFragmentAdapter)mPager.getAdapter()).set_current_position(i);
    }
    
    @Override
    public void onPageScrollStateChanged(int i) {
    }
    // CHANGE ENDS HERE
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using http://www.chaosinmotion.com/flowcover.m and would like to know how I may display a
I'm using http://github.com/bengottlieb/Twitter-OAuth-iPhone/tree/master for Twitter+Oauth in my iPhone app. I'm trying to create a
I am using http://sharpcompress.codeplex.com/ to compress a directory: using (var archive = ZipArchive.Create()) {
I'm using http://jqueryfordesigners.com/jquery-tabs/ for a project, the tabbing javascript code looks like this: <script
I'm using http://jqueryfordesigners.com/jquery-tabs/ for a project, the tabbing code looks like this:- <script type=text/javascript
I'm using http://michelf.com/projects/php-markdown/ for my markdown library and my question is that if i
im using http://www.dhtmlgoodies.com/index.html?whichScript=quiz-maker but i want to be able to display a picture for
using http://www.flotcharts.org/ to realize a complex scatterplot graphic with zoom/pan functionalities, i would like
Using http://maps.google.com/maps/geo?q= .... return latitude and longitude like those : 48.8616441,2.3448885 in a return
I am using http://www.uploadify.com/ but when I upload images with character (čžćšđ) like čžćšđ.jpg

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.