ListView的不良convertView类型BaseAdapter [英] bad convertView type BaseAdapter of ListView

查看:110
本文介绍了ListView的不良convertView类型BaseAdapter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用不同类型的视图行的列表视图的适配器。

I have a list view adapter that uses different types of view rows.

大多数的正常工作时间。但是,当我从列表中删除一个元素崩溃。它发出的不正确类型的convertView到getView

Most of the time it works fine. But when I remove an element from the list it crashes. It sends a convertView of the incorrect type to getView

public View getView(int position, View convertView, ViewGroup patent) ...  

但getItemViewType正在返回正确的类型。

But getItemViewType is returning the correct type.

public int getItemViewType(int position)

所以我看到的东西,看起来像这样

so I see something that looks like this

给我的类型,位置1 - >返回正确的类型(比如1)

give me the type for position 1 -> returns correct type (say 1)

给我的与错误的类型内容视图位置1的视图(比方说是类型2)。

give me a view for position 1 with a content view for the wrong type (say type 2.)

任何想法?

推荐答案

这是正常的,如果你得到一个查看与不同类型 convertView ,您将创建一个新视图,而不是重复使用 convertView

That's normal, if you get a View with different type in convertView, you would create a new View, and not reuse convertView.

大概有给定类型没有可重复使用的意见。

Probably there are no reusable views with the given type.

注意:这个答案是从的 2011 的和可能不再适用

Note: This answer is from 2011 and might no longer apply.

这篇关于ListView的不良convertView类型BaseAdapter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆