tags:

views:

69

answers:

1

I have a ListView that could have 4 different views for a row depending on the data for the row. I have the ListView working correctly overriding getViewTypeCount and getItemViewTYpe. I originally was trying to dynamiclly update the view type count as new views were inflated by forcing calls to getViewTypeCount because it was possible that maybe one or two views may be all that would be needed. The app never functioned correctly crashing after there was more than one view added. The problem was fixed by setting getViewTypeCount to always return 4. I noticed getViewTypeCount is automatically called on app start-up and never called again unless a force call is made. So I'm just curious if this can be changed dynamically or do you need to know the number of max views you can possibly have and override getViewTypeCount to return that max value.

Vince

+3  A: 

Hi,

The view types count cannot be changed dynamically. You need to return the max number of views you are going to use. Note that you can always give a number bigger than what you will actually need, it won't really matter. Just make sure the number is never less than what you'll need :)

Romain Guy