android - 在 ActionBar-PullToRefresh 库中更改加载屏幕的文本

标签 android text android-actionbar pull-to-refresh

我已经成功实现了ActionBar-PullToRefresh在我的代码中。现在,每当我刷新列表时,它都会在 ActionBar 中显示“正在加载...”文本。

那么如何更改 ActionBar 中的文本。我是直接更改库中的字符串还是有任何其他方法可以做到这一点...

最佳答案

样本中认可的方法

来源:https://github.com/chrisbanes/ActionBar-PullToRefresh/tree/master/samples

  1. Create a theme with text overrides (e.g. ptrPullText) ,
    即 res/values/styles.xml:

    <resources>
        <style name="Theme.Holo.CustomPtrHeader" parent="android:Theme.Holo">
            <item name="ptrHeaderStyle">@style/Widget.Custom.PtrHeader</item>
        </style>
        <style name="Widget.Custom.PtrHeader" parent="android:Widget">
            <item name="ptrRefreshingText">Pulling down the internet</item>
        </style>
    </resources>
    
  2. Apply the custom theme to your activity in AndroidManifest.xml

    <activity
        ...
        android:theme="@style/Theme.Holo.CustomPtrHeader" />
    

或者注册你自己的 HeaderTransformer

有关如何执行此操作的示例,请参阅 GridView sample .

或更黑客的方式

请注意setPullText不在HeaderTransformer接口(interface)上,它是DefaultHeaderTransformer的实例方法:

attacher = PullToRefreshAttacher.get(this);
attacher.addRefreshableView(listView, this);
transformer = ((DefaultHeaderTransformer)attacher.getHeaderTransformer());
transformer.setRefreshingText("Pulling down the internet");

关于android - 在 ActionBar-PullToRefresh 库中更改加载屏幕的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18547850/

相关文章:

python - 如何自动替换多个文件文本内容中的一个字符?

android - 根据固定页脚限制 fragment 大小

android - 在 eclipse Android 包中找不到 installLocation 标识符

android - 如何识别当前 fragment ?

python - 没有分隔符时以某种方式分割行的问题

linux - 汇编项目,在 Intel i386 架构上使用 YASM 将行号添加到文本中

android - 方法调用 'setTitle' 可能产生 'java.lang.NullpointerException'

android - 从 Android 中的子 fragment 检索搜索查询?

javascript - Android Webview注入(inject)JS&CSS

android - 使用 ViewPagerIndicator 的 FragmentPagerAdapter 不工作