Im using a Sectioned adapter. Each section has a “subAdapter”.
I get a problem when im removing all sections, and adding new ones. If the new amount of Sections > old amount of sections.
10-27 08:08:33.789: ERROR/AndroidRuntime(21550): java.lang.ArrayIndexOutOfBoundsException
10-27 08:08:33.789: ERROR/AndroidRuntime(21550): at android.widget.AbsListView$RecycleBin.addScrapView(AbsListView.java:5283)
10-27 08:08:33.789: ERROR/AndroidRuntime(21550): at android.widget.AbsListView.trackMotionScroll(AbsListView.java:4092)
10-27 08:08:33.789: ERROR/AndroidRuntime(21550): at android.widget.AbsListView.onTouchEvent(AbsListView.java:2523)
10-27 08:08:33.789: ERROR/AndroidRuntime(21550): at android.widget.ListView.onTouchEvent(ListView.java:3733)
10-27 08:08:33.789: ERROR/AndroidRuntime(21550): at android.view.View.dispatchTouchEvent(View.java:3885)
10-27 08:08:33.789: ERROR/AndroidRuntime(21550): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903)
10-27 08:08:33.789: ERROR/AndroidRuntime(21550): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
10-27 08:08:33.789: ERROR/AndroidRuntime(21550): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
10-27 08:08:33.789: ERROR/AndroidRuntime(21550): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
From what I’ve read this is a problem with getViewTypeCount. Im guessing that the method isn’t called when Im updating the adapter and calling adapter.notifyDataSetChanged();
The problem doesn’t occur if i set a new instance of the adapter as listAdapter.
How can I solve this problem? Can I force the activity to recall getViewTypeCount ?
Correct.
getViewTypeCount()is only called once.Do not change the value of
getViewTypeCount()for the lifetime of your adapter.Not that I am aware of, sorry.