1

I've got a strange situation here.

There's a list view with a custom adapter. The view has a few different item types which are correctly used in getViewItemType. On just about every device and supported OS the getView method in the adapter is called without any weird behavior.

I know getView can be called many times and that isn't the issue. On a Nexus 5 and Nexus 6, however, getView is called twice for the same item type and passes a convertView of null.

The result is we end up creating two views for the same row in the list. It seems that one will actually get attached or added to the listview while the other isn't.

Any suggestions, or tips that might be causing this?

Sababado
  • 2,524
  • 5
  • 33
  • 51

1 Answers1

0

How do you know called twice for same item?

I ran the app with a debugger. It stopped on my breakpoint in getView multiple times (as expected) but two of the stops for the item passed null convertViews. It is a very small list, only four rows, each a different item type. They all show on the screen easily

You should check the position in getView() to make sure if called twice.

I suppose not because that the first time of each item view(convertView) always null, then you need inflate the view with item view layout and return it. While next time show the same view(even though for different item), the convertView will be not null, but you still need set views with value that according to the item position.

Hope you got!

Xcihnegn
  • 11,579
  • 10
  • 33
  • 33