IllegalStateException이 발생할 때 직관적으로 알고 있습니다. 그러나 제 경우에는 소스의 문제가 어디인지 추측 할 수 없습니다. 감히 말하지만, 문제 라인이 있습니다.
private class LoadMoreDataTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
if (isCancelled()) {
return null;
}
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
}
OFFSET = OFFSET + COUNT;
getWallsData();
return null;
}
@Override
protected void onPostExecute(Void result) {
mPostListAdapter.notifyDataSetChanged();
wallPostsList.onLoadMoreComplete();
super.onPostExecute(result);
}
@Override
protected void onCancelled() {
wallPostsList.onLoadMoreComplete();
}
logcat 메시지가 있습니다.
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. [in ListView(2131099757, class com.costum.android.widget.LoadMoreListView) with Adapter(class android.widget.HeaderViewListAdapter)]
문제가 해결되었습니다. 답을 찾았 습니다 ! 제가 한? 스위처, Boolean LOADMORE SWITCHER = false를 추가했습니다. 전역 가시성과 대체 된 mPostListAdapter.notifyDataSetChanged (); doInBackground ()에서 getWallsData ()로.
private Boolean LOADMORE SWITCHER=false;
....
private class LoadMoreDataTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
if (isCancelled()) {
return null;
}
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
}
OFFSET = OFFSET + COUNT;
LOADMORE=true;
getWallsData();
return null;
}
@Override
protected void onPostExecute(Void result) {
// mPostListAdapter.notifyDataSetChanged(); was replaced to getWallsData() body
wallPostsList.onLoadMoreComplete();
super.onPostExecute(result);
}
@Override
protected void onCancelled() {
wallPostsList.onLoadMoreComplete();
}
}
.....
getWallsData(){
...
if(LOADMORE){
mPostListAdapter.notifyDataSetChanged();
LOADMORE=false;
}
}
저는 매우 기쁩니다.이 문제는 더 이상 발생하지 않았습니다.
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. [in ListView(2131099757, class com.costum.android.widget.LoadMoreListView) with Adapter(class android.widget.HeaderViewListAdapter)]
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다