Android Pull To Refresh ListView: eliminate arrow hint
Asked Answered
E

3

5

I am using this library from Chris Banes (I will never thank this man enough). It has two different behaviors depending on the android version. I want to get rid of the graphical hint on the PullToRefresListView (circled in the image below) that is shown only on devices with android lower than 4.0.

Does anybody knows how to do it?

enter image description here

SOLUTION:

for anybody in the future searching for the same solution here it is: in the PullToRefreshAdapterViewBase class change getShowIndicatorInternal method from this:

private boolean getShowIndicatorInternal() {

    return mShowIndicator && isPullToRefreshEnabled();
}

to this:

private boolean getShowIndicatorInternal() {

    return false;
}
Euphemism answered 23/5, 2013 at 9:8 Comment(0)
D
10

If you use a layout XML file, you can also specify ptr:ptrShowIndicator="false" inside the PullToRefreshView's declaration. For example:

    <com.handmark.pulltorefresh.library.PullToRefreshListView
        xmlns:ptr="http://schemas.android.com/apk/res-auto"
        android:id="@+id/pullToRefreshListView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        ptr:ptrShowIndicator="false" >
    </com.handmark.pulltorefresh.library.PullToRefreshListView> 

For other attributes, you can refer to /res/values/attrs.xml in the library, which is self-documented.

You may also find the sample project worth looking at.

Doublespace answered 23/5, 2013 at 10:34 Comment(2)
That's the best! Could you tell me where in the code I can see these attributes? Where can I look to know which attributes I can give to a custom element like com.handmark.pulltorefresh.library.PullToRefreshListView ? Thank you very much!Euphemism
You're welcome~ :) Please see my edited answer for more information.Doublespace
G
2

Quick and dirty- Simply replace the image file for arrow hint with a transparent image in res folder of library.

Garamond answered 23/5, 2013 at 9:31 Comment(0)
T
1

I'd say try to see if you can adjust the code to simply take it out. I don't know if there are any methods added to do this for you, but if there are they should be easy to find.

Scrolling through the code a bit quickly, this might be something;

https://github.com/chrisbanes/Android-PullToRefresh/blob/master/library/src/com/handmark/pulltorefresh/library/internal/IndicatorLayout.java

Although i'm not sure if this is actually that arrow, since it doesn't show any hints in this class about being version-based.

Tiebout answered 23/5, 2013 at 9:19 Comment(3)
Thank you! That was it! Starting from there I had to go through a little bit of other classes to find where it decides if that indicator should be shown or not and set to always return false.Euphemism
Good :) You could separate that into a nice method instead and have it as a setting. Perhaps Chris Banes can accept it as a change and others can enjoy it too ;)Tiebout
Does anyone knows how to show the indicator even if the empty text view is showed when the list is empty?Faints

© 2022 - 2024 — McMap. All rights reserved.