當SwipeRefreshLayout下拉刷新期間,再滑動或者點擊RecyclerView,就會造成
java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position 6(offset:6).state:10
很明顯數組越界,導致這樣的原因是因爲在onRefresh()方法中進行了List.clear(); 數據源被清除,而mAdapter又沒刷新,但此時的視圖是不存在。
解決方法(經測試在recyclerview中使用是沒有問題,listview還是會報錯 - -!):
在List.clear();之前加上
mAdapter.notifyDataSetChanged();