johannilsson/android-pulltorefresh — Issue #36: Crash at startup
Author: dmarcato
Created: 2011-10-24 16:20:08+00:00
State: open

I have implemented PullToRefreshView in my project but sometimes at startup the app crashes with the following log:

```java
10-24 13:16:29.067: E/AndroidRuntime(3667): FATAL EXCEPTION: main
10-24 13:16:29.067: E/AndroidRuntime(3667): java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
10-24 13:16:29.067: E/AndroidRuntime(3667):	at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at java.util.ArrayList.get(ArrayList.java:311)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at android.widget.HeaderViewListAdapter.isEnabled(HeaderViewListAdapter.java:164)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at android.widget.ListView.dispatchDraw(ListView.java:3061)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at android.view.View.draw(View.java:7003)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at android.widget.AbsListView.draw(AbsListView.java:2641)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at android.view.View.draw(View.java:6900)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at android.view.View.draw(View.java:6900)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at android.widget.FrameLayout.draw(FrameLayout.java:357)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at android.view.View.draw(View.java:6900)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at android.widget.FrameLayout.draw(FrameLayout.java:357)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1908)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at android.view.ViewRoot.draw(ViewRoot.java:1527)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at android.view.ViewRoot.performTraversals(ViewRoot.java:1263)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at android.view.ViewRoot.handleMessage(ViewRoot.java:1865)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at android.os.Handler.dispatchMessage(Handler.java:99)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at android.os.Looper.loop(Looper.java:130)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at android.app.ActivityThread.main(ActivityThread.java:3835)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at java.lang.reflect.Method.invokeNative(Native Method)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at java.lang.reflect.Method.invoke(Method.java:507)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
10-24 13:16:29.067: E/AndroidRuntime(3667):	at dalvik.system.NativeStart.main(Native Method)
```

Is there someting I am doing wrong? I have added the widget in my xml and set adapter in onCreate...