[問題]使用AsyncTask更新List資料的問題
大家好,
我使用AsyncTask非同步的去伺服器取得一個ArrayList
讓adapter吃進ArrayList並動態更新ListView裡Item的資料.
點擊Item時會取得Item Position並再去後台取得詳細資訊,
之後用一個Activity呈現這個資訊.
但現在在點擊Item時三不五時就會出現下列Exception:
java.lang.IllegalStateException: 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.
Google之後我有修正更新通知:
private class getDispatchedTask extends AsyncTask<String, Integer, String>{
...
protected void onPostExecute(String result) {
...
adapter.notifyDataSetChanged();
}
}
但問題還是會發生
請教高手協助
謝謝~
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.168.106.64
※ 文章網址: http://www.ptt.cc/bbs/AndroidDev/M.1400928984.A.94F.html
→
05/24 18:58, , 1F
05/24 18:58, 1F
推
05/24 19:43, , 2F
05/24 19:43, 2F
推
05/24 20:15, , 3F
05/24 20:15, 3F
推
05/24 20:21, , 4F
05/24 20:21, 4F
推
05/24 21:37, , 5F
05/24 21:37, 5F
推
05/24 23:12, , 6F
05/24 23:12, 6F
推
05/24 23:31, , 7F
05/24 23:31, 7F
推
05/25 09:35, , 8F
05/25 09:35, 8F
→
05/25 10:45, , 9F
05/25 10:45, 9F