Why does getCount in adapter is being called so many times?

user1787773 picture user1787773 · Nov 26, 2012 · Viewed 7.6k times · Source

I have a custom list and it takes few minutes to show-up. When I was trying to check where the problem is, I saw that even when I have only 1 item in the list, the method getCount() is being called 5 times, getVIew() is being called once, an then getCount() is being called to more time. Overall getCount() is being called 7 times. Does that makes sense?

Thank you!

Answer

sdabet picture sdabet · Nov 26, 2012

You can see here the different internal calls to the Adapter.getCount() method.

But you must keep in mind that you have no control on how this method is gonna be called.

It can be called multiple times and that's why you have to keep it as fast as possible.