Coder Social home page Coder Social logo

erikwt / pulltorefresh-listview Goto Github PK

View Code? Open in Web Editor NEW
635.0 635.0 325.0 738 KB

A generic, customizable, open source Android ListView implementation that has 'Pull to Refresh' functionality.

Home Page: https://github.com/erikwt/PullToRefresh-ListView

Groovy 19.67% Java 80.33%

pulltorefresh-listview's People

Contributors

erikwt avatar osheas avatar pokowaka avatar vibu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pulltorefresh-listview's Issues

PullToRefresh banner gets locked when scrolling quickly

I have a similar problem to issue #40, loosing the ability to pull to refresh. It is possibly the same bug. I found a consistent way to reproduce it in my app was to:

  • Load a fresh page (therefore at the top of the list).
  • "Fling" scroll towards the bottom of the list
  • Before the previous "fling" scroll downwards has finished, "fling" back to the top of the page.
  • Finally, try to pull to refresh.

If you don't know what I mean by "fling", see onFling at http://developer.android.com/reference/android/view/GestureDetector.OnGestureListener.html . It is a fast scroll and release. The page continues to scroll even though your finger has left the page.

Looking at the code, the reason the refresh is not happening is that in PullToRefreshListView -- onTouchEvent, ACTION_MOVE is being called but previousY==-1. The first if statement therefore does not pass.

The difference between the above method and this:

  • Fresh page
  • Fling down
  • Wait for fling to finish
  • Fling to top
  • Pull to refresh (successful)

is that ACTION_DOWN is not called in the latter case, but is in the former, setting previousY = -1. I believe the ACTION_DOWN code is there for the purpose of stopping a user performing a pull to refresh unless they have started their pull from the top of the list. I think this makes sense.

My solution to this issue is to include:

previousY = event.getY();

to ACTION_UP, just before the break statement, outside of the if.

case MotionEvent.ACTION_UP:
    if(previousY != -1 && (state == State.RELEASE_TO_REFRESH || getFirstVisiblePosition() == 0)){
        switch(state){
            case RELEASE_TO_REFRESH:
                setState(State.REFRESHING);
                bounceBackHeader();

                break;

            case PULL_TO_REFRESH:
                resetHeader();
                break;
        }
    }
    previousY = event.getY(); // --- HERE ---
    break;

I am not sure if there will be unintended consequences to this. I have started testing and it seems to work. I will keep you posted.

InflateException: Binary XML file

I have added the jar from libraryproject\bin, to my project, I was able to access the class in .java classes but in the .xml file I get InflateException on "<eu.erikw.PullToRefreshListView" , "Caused by: java.lang.ClassNotFoundException: eu.erikw.PullToRefreshListView" .
Please tell me how to solve this issue.

I solved it, but I had to copy the files from library in project....

ClassCastException android.widget.HeaderViewListAdapter using CustomAdapter

I'm getting this error when I perform the refreshing of the list.

First, when the activity is created, in the onResume() method I populate my custom adapter for the list, and everything goes smooth. The list is populated and I'm able to interact with it.
Then, if I make the drag movement to refresh the list, I get this error when retrieving the list adapter in order to refresh it. I post the code below:

private void refreshListAdapter() {
NewsListAdapter adapter = (NewsListAdapter)ptrList.getAdapter();
if (adapter == null) {
adapter = new NewsListAdapter(NewsActivity.this);
ptrList.setAdapter(adapter);
} else {
adapter.populateAdapter();
}
ptrList.onRefreshComplete();
}

Is not possible to use custom adapters or have them to extend from HeaderViewListAdapter?

Can you help me? Thank you in advance.

David.

Customize the distance from when "Release to refresh" is showed

I digged trough the code, but couldn't really find where that is specified, I guess somewhere via headerPadding?

Would be nice if there was a constant where we could specify how "far down" one has to pull until the "release to refresh" is showed (basically to make unintentional updating less happening =D)

thanks for your great work!

eu.erikw.PullToRefreshListView failed to instantiate

After I added a progressbar on the view where PullToRefreshListView stayed on, errors occurred. If I delete the progressbar, then it is good again. So can PullToRefreshListView share with other views? Thanks!

Here is the xml file for a fragment:

<eu.erikw.PullToRefreshListView
    android:id="@+id/lvTweets"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true" >
</eu.erikw.PullToRefreshListView>

<ProgressBar
    android:id="@+id/pbLoading"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true" />

And below is the error stack:

java.lang.ClassCastException: android.widget.ImageView cannot be cast to android.widget.RelativeLayout
at eu.erikw.PullToRefreshListView.init(PullToRefreshListView.java:229)
at eu.erikw.PullToRefreshListView.(PullToRefreshListView.java:100)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.instantiateClass(ProjectCallback.java:422)
at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.loadView(ProjectCallback.java:179)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:135)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:755)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:373)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:400)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:336)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:333)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderService.createRenderSession(RenderService.java:451)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:1545)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.recomputeLayout(GraphicalEditorPart.java:1302)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart$ReloadListener.reloadLayoutSwt(GraphicalEditorPart.java:1777)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart$ReloadListener.access$0(GraphicalEditorPart.java:1715)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart$ReloadListener$1.run(GraphicalEditorPart.java:1709)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4144)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1053)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:942)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:588)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
at org.eclipse.equinox.launcher.Main.main(Main.java:1414)

java.lang.IllegalStateException

Hi,
I have the following error:

java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. [in ListView(2131296374, class eu.erikw.PullToRefreshListView) with Adapter(class android.widget.HeaderViewListAdapter)]
at android.widget.ListView.layoutChildren(ListView.java:1538)
at android.widget.AbsListView.onTouchEvent(AbsListView.java:3702)
at eu.erikw.PullToRefreshListView.onTouchEvent(PullToRefreshListView.java:350)
at android.view.View.dispatchTouchEvent(View.java:7149)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2173)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1908)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2179)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1922)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2179)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1922)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2179)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1922)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2179)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1922)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2179)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1922)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2198)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1574)
at android.app.Activity.dispatchTouchEvent(Activity.java:2582)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2147)
at android.view.View.dispatchPointerEvent(View.java:7329)
at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3202)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3144)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4183)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4162)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4271)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:171)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:125)
at android.os.Looper.loop(Looper.java:124)
at android.app.ActivityThread.main(ActivityThread.java:4941)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:561)
at dalvik.system.NativeStart.main(Native Method)

How can I solve that? I've just implemented the PullToRefreshView like in the sample code.

Thanks

Bounce back animation problems

The bounce back action doesn't render items that were "out of view" due to pulling down the header. Is there a way to somehow render the other items instead of using the cache color?

Place listView below another view

Problem building listView below another view like this:

<eu.erikw.PullToRefreshListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/viewTitle"/>

When pulling down the list and it bounces back after refreshing. It is not bouncing back beneath the viewTitle but on top of it. When it´s finished refreshing it´s moving upwards on top of the viewTitle for 700ms and then disappears. I want it beneath that layer from the beginning like you put a paper beneath another paper or like in your sample code where it disappears beneath the title bar (PullToRefresh SampleProject).

A workaround is to lower the BOUNCE_ANIMATION_DURATION to 5ms but that is too fast to look good.

NullPointerException when there is nothing to fetch.

How can you reproduce? When there is nothing to fetch, if you perform a click on the listview header, NPE occurs. I've solved it by adding "if(mOnItemClickListener != null && mState!=State.REFRESHING)". So the item click listener will not be consumed.

The mOnItemClickListener (see point [1] below) is not null but it throws NPE because the arguments of the listener are null, because the event is not performed on any of the child items.
In class:
private class PTROnItemClickListener implements OnItemClickListener{

    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
        mHasResetHeader = false;

        if(mOnItemClickListener != null && mState!=State.REFRESHING){  
            mOnItemClickListener.onItemClick(adapterView, view, position, id); ///      [1] 
        }
    }
}

Looking forward your feedback. Cheers!

OnItemClickListener & OnItemLongClickListener

Our ListView uses OnItemClickListener to switch to a detail view, and OnItemLongClickListener to reveal a button in the ListView item. I've switched to a PullToRefreshListView, and I find I still get these listeners firing when I'd expect the view to be consuming the touch events as part of the pull-to-refresh functionality. E.g. press and slowly move down, we start to reveal the 'pull to refresh' row at the top of the list, but we then get our OnItemLongClickListener called. Or pull down swiftly for 1/2 a row, again we see the 'pull to refresh' start to be displayed, but if you then release the touch we get the OnItemClickListener called.

This feels wrong, I'd expect to have these Listeners called only if we're not doing any pull to refresh action. Is this how it's meant to work? Or is there some way I can configure it to behave the way we need?

ClassCastException preventing PullToRefreshListView from inflating

I get the following error message when using your library:

10-28 23:39:06.536: E/AndroidRuntime(4486): Caused by: java.lang.ClassCastException: com.actionbarsherlock.internal.widget.ActionBarView$HomeView cannot be cast to android.widget.LinearLayout
10-28 23:39:06.536: E/AndroidRuntime(4486):     at eu.erikw.PullToRefreshListView.init(PullToRefreshListView.java:241)
10-28 23:39:06.536: E/AndroidRuntime(4486):     at eu.erikw.PullToRefreshListView.<init>(PullToRefreshListView.java:113)

How I got the error

I put a PullToRefreshListView in a layout XML called home.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <eu.erikw.PullToRefreshListView
        android:id="@+id/listview"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

</LinearLayout>

I inflated this XML in a fragment called Home.java, which, in turn, I attached to a SherlockActivity (from the open-source library ActionBarSherlock) called MainActivity.java:

Home.java

public class Home extends Fragment {
    private PullToRefreshListView l;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        // Layout
        View v = inflater.inflate(R.layout.home, container, false); 
        l = (PullToRefreshListView) v.findViewById(R.id.listview);

        //Return
        return v;
    }
}

MainActivity.java

public class MainActivity extends Master {
    // Tabs listener
    private class TabsListener implements ActionBar.TabListener {
        private Fragment fragment;
        private String tag;

        public TabsListener(Fragment fragment, String tag) {
            this.fragment = fragment;
            this.tag = tag; 
        }

        @Override
        public void onTabReselected(Tab tab, FragmentTransaction ft) {
        }

        @Override
        public void onTabSelected(Tab tab, FragmentTransaction ft) {
            ft.replace(R.id.fragment_container, fragment, tag);
        }

        @Override
        public void onTabUnselected(Tab tab, FragmentTransaction ft) {
            ft.remove(fragment);
        }

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        // Setup
        super.onCreate(savedInstanceState);

        // Assignments
        context = getApplicationContext();

        // Layout
        getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        getSupportActionBar().setDisplayHomeAsUpEnabled(false);
        setContentView(R.layout.activity_main);

        Fragment fHome;
        if((fHome = getSupportFragmentManager().findFragmentByTag(HOME)) == null) fHome = new Home();

        ActionBar.Tab tab = getSupportActionBar().newTab();
        tab.setIcon(R.drawable.home);
        tab.setContentDescription("Home");
        tab.setTabListener(new TabsListener(
            fHome,
            "hom"
            ));
        getSupportActionBar().addTab(tab, false);
        }
}

Other potentially relevant info

I cloned your GitHub, imported the project into Android, then added it as a library to my own project. I made no modifications to your code.

bouncing animation problem

i’ve a RelativeLayout with an height of 50dp and under it i’ve the pull list, but when i trigger the refresh action the list with the bouncing animation moves over the Relative layout so over it i can see the pull to refresh label and the progress bar ….

i can’t reproduce the error with your example code because on import the sample project doesn’t see the lib on property->android-library library reference list.

NOTE: on XML code you will that i’ve renamed your class because i use 2 pull to refresh lib in different sections and they can’t be with the same name...

XML code ( only mentioned part ):

</RelativeLayout>

<eu.erikw.PullToRefreshListViewForLoadMore 
    android:id="@+id/pull_to_refresh_listview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="@+id/layoutContent"
        android:paddingBottom="9dp"
        android:clipToPadding="false"
    android:divider="#00FFFFFF"
    android:dividerHeight="9dp"
    android:visibility="gone" />

setOnItemClickListener has the wrong position.

The position is wrong (may be -1) if item is clicked when pulling or refreshing.

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {

        }
    });

Caused by: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.RelativeLayout

E/AndroidRuntime(26414): java.lang.RuntimeException: Unable to start activity ComponentInfo{eu.erikw.pulltorefresh.sample/eu.erikw.pulltorefresh.sample.PullToRefreshListViewSampleActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class eu.erikw.PullToRefreshListView
E/AndroidRuntime(26414):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
E/AndroidRuntime(26414):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
E/AndroidRuntime(26414):    at android.app.ActivityThread.access$800(ActivityThread.java:135)
E/AndroidRuntime(26414):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
E/AndroidRuntime(26414):    at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(26414):    at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime(26414):    at android.app.ActivityThread.main(ActivityThread.java:5017)
E/AndroidRuntime(26414):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(26414):    at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime(26414):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
E/AndroidRuntime(26414):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
E/AndroidRuntime(26414):    at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(26414): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class eu.erikw.PullToRefreshListView
E/AndroidRuntime(26414):    at android.view.LayoutInflater.createView(LayoutInflater.java:620)
E/AndroidRuntime(26414):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
E/AndroidRuntime(26414):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
E/AndroidRuntime(26414):    at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
E/AndroidRuntime(26414):    at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
E/AndroidRuntime(26414):    at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
E/AndroidRuntime(26414):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
E/AndroidRuntime(26414):    at android.app.Activity.setContentView(Activity.java:1929)
E/AndroidRuntime(26414):    at eu.erikw.pulltorefresh.sample.PullToRefreshListViewSampleActivity.onCreate(PullToRefreshListViewSampleActivity.java:40)
E/AndroidRuntime(26414):    at android.app.Activity.performCreate(Activity.java:5231)
E/AndroidRuntime(26414):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
E/AndroidRuntime(26414):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
E/AndroidRuntime(26414):    ... 11 more
E/AndroidRuntime(26414): Caused by: java.lang.reflect.InvocationTargetException
E/AndroidRuntime(26414):    at java.lang.reflect.Constructor.constructNative(Native Method)
E/AndroidRuntime(26414):    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
E/AndroidRuntime(26414):    at android.view.LayoutInflater.createView(LayoutInflater.java:594)
E/AndroidRuntime(26414):    ... 22 more
E/AndroidRuntime(26414): Caused by: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.RelativeLayout
E/AndroidRuntime(26414):    at eu.erikw.PullToRefreshListView.init(PullToRefreshListView.java:229)
E/AndroidRuntime(26414):    at eu.erikw.PullToRefreshListView.<init>(PullToRefreshListView.java:100)
E/AndroidRuntime(26414):    ... 25 more
W/ActivityManager(  776):   Force finishing activity eu.erikw.pulltorefresh.sample/.PullToRefreshListViewSampleActivity

Adapter notifyDataSetChanged() is not working

Thanks Eric for the great feature,

I am having a problem with the list adapter it is not rendering the status of my linear layout after the onClickItem, while using the regular listView everything works just fine. Any suggestions to make the adapter work with your pull to refresh listView??
thanks again,

Ali Tazami

Adding layout animation does not work.

There seems to be an issue when adding a layout animation set to PullToRefreshListView via ListView's setLayoutAnimation. The animations being set do not work/run.

I haven't tested this issue extensively, but I did have working code that used a ListView and would run a simple animation when an item was added to the list. When I swapped the ListView for a PullToRefreshListView, the animation would no longer run.

How to use with listfragment

HI,
Wonderful work , but i have a very large project that uses several listfragments, so how do I use pulltorefresh there?

Each time I pull to refresh my item in the list is clicked

Hi,
I'm trying to use your project but actually I'm having a problem with the ClickEvent.
Each time I do pull to refresh, the item pressed under my finger is called with the ClickEvent. I need to be able to do click the items but not when i'm refreshing it.
I've been trying to control the list onItemClick event with the method isRefreshing() but before the State is updated, the Item Click Event is called and launch the detail associated to this item.
Is there any way to control the pass of the event?

Ps: when I declare the < eu.erikw.PullToRefreshListView.. I've added the android:clickable="false"/>.

onRefresh() is not called when I force it with setRefreshing()

I assume that it should be called but instead only the progress bar continues spinning.
It seems you have a bug in the method

public void setRefreshing(){
state = State.REFRESHING;
scrollTo(0, 0);
setUiRefreshing();
setHeaderPadding(0);

}

This method should be changed to:

public void setRefreshing(){
setState(State.REFRESHING);
scrollTo(0, 0);
setUiRefreshing();
setHeaderPadding(0);

}

By setting the state this way the onRefreshListener.onRefresh(); is called.

Android ClassNotFoundException PullToRefreshListView

I add the PullToRefreshListView.java source code into my package, the app runs well before I packaged it with progard.cfg, but it went wrong after that operation
And it throw ClassNotFoundException Error.

07-19 15:09:14.776: E/AndroidRuntime(585): Caused by: java.lang.ClassNotFoundException: com.xx.xxx.widget.PullToRefreshListView

this happended after I update my ADT(this ADT can send warn infos in the XML file). it goes well before I update this ADT.
And I tried to update the Android SDK too, still not working.

and I add this PullToRefreshListView widget in the XML file like this:

    <com.xx.xxx.widget.PullToRefreshListView
        android:id="@+id/contentFlowList"
        style="@style/pull_refresh_listview_style"
        android:listSelector="@android:color/transparent" >
    </com.xx.xxx.widget.PullToRefreshListView>

the ADT version20.0.1's requirement is here. And I checked nothing's wrong with the environment.

I can directly run the App successfully, but crash happends when jump to the Activity containing PullToRefreshListView after I obfuscated code and packaged it.

How can I solve this problem

ptr_header.xml should include layout_width/layout_height or it will cause exception

I have added it like here:




    <LinearLayout android:id="@+id/ptr_id_textwrapper" style="@style/ptr_textwrapper">
        <TextView android:id="@+id/ptr_id_text" style="@style/ptr_text"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content" />
        <TextView android:id="@+id/ptr_id_last_updated" style="@style/ptr_last_updated"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>
</RelativeLayout>

main.xml should add these too.

listview items not completely displayed

I am using a listview that partially occupies the screen. Now when my items exceed the rows shown by default, the last item when finger scrolled down is only shown half and not the full cell row.

Divider appears before the first item

Divider appears before the first item, how do i get rid of that?
I have a 10dp of divider height between items, but I don't want it to appear before the first item.
android listview doesn't do that, but using this library does. How de we solve it?

PTRListView below other layouts

When we pull the list down the messages appear fine, the only problem is that the message comes above the other layout i have in the activity, then it disappears when the update is finished. It is like it does not know the position it should be within the listview. Maybe this library should only be used when the listview occupy the activity as a whole but not as a part of it!?

Flicker when setAdapter

When re-loading the listView in the code (listView.setAdapter(adapter)), the header with the text "Pull to refresh" and the arrow is shown for a fraction of a second every time. Maybe it´s not possible to solve?

A solution is to define adapter globally and do the listView.setAdapter(adapter) one time only on onCreate. Then only do adapter.loadData() to update the view. Maybe that is the intended way to code..

Refresh incorrectly triggers when doing a continuous long touch

Reproduction

  1. Start by pulling the listview to refresh, the header changes state to "Release to refresh"
  2. Instead of letting go of the finger scroll back down and start scrolling up again

Expected result:

The list is not refreshed

Actual result:

The list is locked, refreshing commences

Create public methods for setting text in header.

This is a feature request to create public methods for setting text in header. More specifically, public methods for changing 'Pull to refresh' and 'Release to refresh' text, to either something else or to nothing at all.

With this being open-source, it was easy enough for me to hack in a solution, but I believe these are good public methods to have. See the PullToRefreshBase.java file of Chris Banes' project for something similar (https://github.com/chrisbanes/Android-PullToRefresh).

Thanks!

List Index problem

Hi,
I used the pulltorefresh as the custom listview and there is a problem.
On click of a particular item, the previous item gets loaded.
Do you know what might be the problem ?
Is this an issue?
Thank you.

Layout Error

During layout, the view will not be correctly loaded because of line 45 in ptr_default_style.xml. The ? should be replaced with a '@':

    <item name="android:textAppearance">@android:attr/textAppearanceMedium</item>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.