Android ListView IndexOutOfBoundsException

Android ListView IndexOutOfBoundsException,android,android-listview,crash,indexoutofboundsexception,Android,Android Listview,Crash,Indexoutofboundsexception,我在我的适配器中收到关于IndexOutOfBoundsException的崩溃报告,它从未在我的设备上发生过,所以我不知道发生了什么情况 在我的getView上,it崩溃(itemlist.get(position)): 当然,我覆盖了getcount,正如我提到的,它从未发生在我身上,但我有时会收到发生在usersaa上的报告 public int getCount() { return itemlist.size(); } 你知道这是怎么回事吗?以及如何防止它吗?你应该用父项代替

我在我的适配器中收到关于IndexOutOfBoundsException的崩溃报告,它从未在我的设备上发生过,所以我不知道发生了什么情况

在我的getView上,it崩溃(itemlist.get(position)):

当然,我覆盖了getcount,正如我提到的,它从未发生在我身上,但我有时会收到发生在usersaa上的报告

public int getCount() {
    return itemlist.size();
}

你知道这是怎么回事吗?以及如何防止它吗?

你应该用父项代替itemlist从列表中获取数据

Object item = parent.getItemAtPosition(position);

String text=item.toString();

我解决了。这是我的答案。


您要做的是找出视图导致此异常的原因。并确保一旦数据更改,立即通知适配器!

请输入适配器代码!父视图是我的视图组,我不太了解解决方案。
Object item = parent.getItemAtPosition(position);

String text=item.toString();