Android報錯:The content of the adapter has changed...與Channel is unrecoverably broken and will be disposed的分析與解決辦法


在Android中adapter錯誤:

The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread。

分析:

這個錯誤通常是listview等控件在使用adapter適配數據時可能傳入的是一個靜態的list,而在adapter中直接使用=號來賦值,當外部這list被改變(如多線程操作了這個list)后沒有及時的調用adapter的notifyDataSetChanged,導致下次來更新的時候報錯。

解決:

在adapter中不要直接用=號來賦值,使用如下兩種方法重新分配內存:

1:list.clear ,list.addall。

2:arraylist.clone。

------------------------------------------------------------------------

Android錯誤:Channel is unrecoverably broken and will be disposed!  

分析:

在使用某些方法時傳入的參數有問題或格式錯誤。如:Integer.parseInt("")

解決:

找到導致問題的地方,先做判斷再傳值。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM