Sometimes I notice that, for a View v
- v.hasWindowFocus()==false
- ((View)v.getParent()).hasWindowFocus())==true
If I understand the docs correctly, this should never be the case.
v.getParent() is a (subclass) of ListView
Any ideas on what might be causing this?
Note: I assume this hasWindowFocus-mismatch is the root cause for this issue
The main reason is that ListView doesn’t like an adapter having an array of views.
So the problem is triggered by code like
When looking at the ListView code (or rather it’s parents AbsListView.obtainView method) you’ll see code like
It can happen that
getView(position,...)is called with scrapView != _views[position] and hence scrapView will be recycled. On the other hand, it is quite likely that the same view is also added again to ListView, resulting in views getting weird states.This should be fixed in ListView IMO.