Yeah, that's not surprising.
> I noticed that if I scroll slowly, this error can be avoided, but if I
> scroll rapidly through the last pending row it will cause this
> exception.
Really? I would have expected it to fail all of the time.
> I am able to reproduce this in the EndlessAdapter demo code
> (EndlessAdapterDemo.java) by calling addHeaderView to the ListView
> before setting the adapter:
>
> @Override
> public void onCreate(Bundle icicle) {
> super.onCreate(icicle);
> setContentView(R.layout.main);
>
> ArrayList<Integer> items=new ArrayList<Integer>();
>
> for (int i=0;i<25;i++) { items.add(i); }
>
> getListView().addHeaderView(new View(this));
> setListAdapter(new DemoAdapter(items));
> }
>
> Any thoughts on what I can do to alleviate this?
EndlessAdapter has a built-in assumption that it is the top-level
adapter. However, when you call addHeaderView() or addFooterView(),
Android creates its own decorating adapter, wrapped around
EndlessAdapter, and installs its adapter as the top level.
You can try an EndlessAdapter around a MergeAdapter
(https://github.com/commonsguy/cwac-merge) to see if that will give
you your header. I have this sneaking suspicion that this combination
will introduce its own set of problems, but it's at least worth
considering.
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy
Android Training in NYC: http://marakana.com/training/android/