[英]can i delete array of listView but not update listview?
我花了一些時間在Google上搜索,但沒有幫助。
我有一個包含ArrayList
的列表視圖。
我可以收集數組中的所有數據,在listView中顯示它並刪除數組,但不能更新listView-這樣數據就會顯示在屏幕上嗎?
是的,直到將列表視圖滾動到下一個可見項目(或調用通知項目集更改),然后ListView
要求適配器在第5個位置提供對象,例如,您將獲得ArrayIndexOutOfBoundsException
或NullPointerException
。 因此,如果要避免這種情況,必須將列表元素復制到另一個ArrayList實例,然后將其傳遞給適配器。
arrayListMain.get(position).remove(arrayListChild.get(position));
notifydatasetchange();
arrayListMain是您在setAdapter上使用的arraylist,而arraylistChild是適配器中的arrayList
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.