ListView.hasWindowFocus==true but child views hasWindowFocus==false

你。 提交于 2019-12-02 10:50:46

The main reason is that ListView doesn't like an adapter having an array of views.

So the problem is triggered by code like

public View getView (int position, View convertView, ViewGroup parent)
{
    return _views[position];
}

When looking at the ListView code (or rather it's parents AbsListView.obtainView method) you'll see code like

    if (scrapView != null) {
        ...
        child = mAdapter.getView(position, scrapView, this);
        ...
        if (child != scrapView) {
            mRecycler.addScrapView(scrapView);

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!