更改ViewPagerIndicator到图标,而不是文本 [英] Change ViewPagerIndicator to Icon, not Text

查看:244
本文介绍了更改ViewPagerIndicator到图标,而不是文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用下面的库:
https://github.com/JakeWharton/Android-ViewPagerIndicator
设置ViewPagerIndicator(TitlePageIndicator)

I'm using the following library: https://github.com/JakeWharton/Android-ViewPagerIndicator to set a ViewPagerIndicator(TitlePageIndicator)

TitlePageIndicator titleIndicator = (TitlePageIndicator) findViewById(R.id.someId);

我很难codeD,字符串的声明数组

I have a hardcoded, declared array of String

private static final String[] CONTENT = new String[] { "#", "Home", "Icon" }; 

在我ViewPager适配器,我简单地设置选项卡的名称,像这样:

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.

我们可以看到, Pinterest的这是否与他们的主力中锋选项卡。

As we can see, Pinterest does this with their main center tab.

先谢谢了。

推荐答案

看看从ViewPageExtensions项目FixedIconTabs例子的 1 。这是你想要的吗?

Take a look at the FixedIconTabs example from the ViewPageExtensions project 1. Is that what you want ?

1 - 的 https://github.com/astuetz/ViewPagerExtensions

编辑 - 添加图片

这篇关于更改ViewPagerIndicator到图标,而不是文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆