0

I used https://github.com/johannilsson/android-pulltorefresh for pull to refresh in my listview

this is the code.......... in AsyncTask onPostExecute I wrote this one

adapter=new ServicesTypeTranDetailAdapter(getActivity(), items_list_trandetails);
servicesList.onRefreshComplete();
servicesList.setAdapter(adapter);

I was doing same functionality I didn't get any error. If am I kept the device idle for two hours then I got this error. Please help me. Thanks in advance...

FATAL EXCEPTION: main

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(2131165659, class com.isp.activities.PullToRefreshListView) with Adapter(class android.widget.HeaderViewListAdapter)]
    at android.widget.ListView.layoutChildren(ListView.java:1538)
    at android.widget.AbsListView.onTouchModeChanged(AbsListView.java:2977)
    at android.view.ViewTreeObserver.dispatchOnTouchModeChanged(ViewTreeObserver.java:606)
    at android.view.ViewRootImpl.ensureTouchModeLocally(ViewRootImpl.java:2761)
    at android.view.ViewRootImpl.ensureTouchMode(ViewRootImpl.java:2745)
    at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:2872)
    at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2466)
    at android.view.ViewRootImpl.processInputEvents(ViewRootImpl.java:845)
    at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2475)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4424)
    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:784)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    at dalvik.system.NativeStart.main(Native Method)
Wesley
  • 4,084
  • 6
  • 37
  • 60
pandu
  • 209
  • 1
  • 2
  • 8
  • Share your stack tace and code – Rajnish Mishra Jul 22 '14 at 11:47
  • this link will help you http://stackoverflow.com/questions/3132021/android-listview-illegalstateexception-the-content-of-the-adapter-has-changed – Pawan asati Jul 22 '14 at 11:47
  • servicesList.onRefreshComplete(); servicesList.setAdapter(adapter); i think you should setAdapter first and refresh later not sure though – Illegal Argument Jul 22 '14 at 11:51
  • earlier I did setAdapter first and refresh later but at that time also I got the error – pandu Jul 22 '14 at 11:54
  • try adding adapter.notifyDataSetChanged(); – Illegal Argument Jul 22 '14 at 11:57
  • I also tried this one but even also I am getting this error while my device is idle for 2hours. And also tried this one also getActivity().runOnUiThread(new Runnable(){ @Override public void run() { – pandu Jul 22 '14 at 12:00
  • I added My stack trace. And also I tried with adapter.notifyDataSetChanged(); But this error happens only while kept my device idle for more than 2 hours – pandu Jul 23 '14 at 04:46

0 Answers0