Have you tested this? because i do not see how this will work. When headers have been scrolled passed they will no longer be in the view hierarchy meaning  for (int i = headerCount; i < headerEnd; i++) will now skip actual list items (not just the headers). This is the same ofr footers. They will not be part of the view hierarchy until visible, meaning that in this case you will never iterate over the bottom list items on screen if you have added footers to the listview