是否有人知道如何使用PagerTitleStrip Android中 [英] Does someone know how to use PagerTitleStrip in Android

查看:161
本文介绍了是否有人知道如何使用PagerTitleStrip Android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我决定使用 ViewPager 在我的应用程序,一切工作正常。 我知道,我想用一个 PagerTitleStrip 在我的 ViewPager ,但我一直没能找到有关的任何信息去做吧... 唯一的一个页面(原文如此!)我发现这个类是<一个href="http://developer.android.com/reference/android/support/v4/view/PagerTitleStrip.html">http://developer.android.com/reference/android/support/v4/view/PagerTitleStrip.html 这样看来,我只需要添加 PagerTitleStrip 我的 ViewPager 的布局中,但我没有看到任何新的东西我的活动......

I decided to use a ViewPager in my application and everything is working fine. I Know that I want to use a PagerTitleStrip in my ViewPager, but I've failed to find any info on how to do it... The one and only page (sic!!) I found on this class is http://developer.android.com/reference/android/support/v4/view/PagerTitleStrip.html So it seems I just need to add the PagerTitleStrip within my ViewPager layout, but I don't see anything new on my activity...

<android.support.v4.view.ViewPager
    android:id="@+id/viewPager"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <android.support.v4.view.PagerTitleStrip
        android:id="@+id/pagerTitleStrip"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom" />
</android.support.v4.view.ViewPager>

有谁知道如何使用它?

Does anyone know how to use it?

编辑: 对不起它实施的 getPageTitle 方法时的工作 ViewPagerAdapter ...但我不想显示的任何文字,只是一个小光标显示当前视图相比,previous和旁边的人的位置...

Edited: Sorry it works when implementing the getPageTitle method in the ViewPagerAdapter... but I don't want any text displayed, just a small cursor to show the position of the current View compared to the previous and next ones...

推荐答案

我不知道你的情况是什么造成的错误,但我这是怎么用它,在你的布局,你应该后面插入code在布局

I'm not sure what causing error in your case but this is how I use it, in your layout you should insert following code in your layout:

<android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center" >

        <android.support.v4.view.PagerTitleStrip
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="top" />
</android.support.v4.view.ViewPager>

那你应该添加以下code在PageAdapter:

Then you should add the following code in your PageAdapter:

        @Override
        public CharSequence getPageTitle (int position) {
            return "Your static title";
        }

这是pretty的吧。

That's pretty it.

这篇关于是否有人知道如何使用PagerTitleStrip Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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