I’m using the following library:
https://github.com/JakeWharton/Android-ViewPagerIndicator
to set a ViewPagerIndicator(TitlePageIndicator)
TitlePageIndicator titleIndicator = (TitlePageIndicator) findViewById(R.id.someId);
I have a hardcoded, declared array of String
private static final String[] CONTENT = new String[] { "#", "Home", "Icon" };
and in my ViewPager Adapter, I simply set the name of the tab like so:
public CharSequence getPageTitle(int position) {
return CONTENT[position % CONTENT.length].toUpperCase();
}
This all works fine. My question is- can I change the tab “title” to an icon instead of text? Is this possible? If not, is there any other tool I should be using to achieve this?
I have looked at the “stock” examples, and I have not seen something like an icon.
As we can see, Pinterest does this with their main center tab.
Thanks in advance.
Take a look at the FixedIconTabs example from the ViewPageExtensions project 1. Is that what you want ?
1 – https://github.com/astuetz/ViewPagerExtensions
Edit – Adding a pic