제 3 자 클라우드 서비스 (Kinvey)를 사용하여 앱의 데이터를 가져옵니다. 서비스가 비동기 클래스로 래핑 된 모든 Kinvey 메소드. 나는 현재 아래에 오류 로그를 받고 있는데 왜 나는 그것을 얻고 있는지 이해한다. 나는 그 문제를 해결하는 방법을 모른다.콘텐츠 어댑터 및 비동기 콜백
오류 : 어댑터를 업데이트
mKinveyClient.appData("artistdata", ArtistData.class).delete(artistID, new KinveyDeleteCallback() {
@Override
public void onSuccess(KinveyDeleteResponse result) {
Log.e("DELEET", "Data Deleted sucessfully");
Toast.makeText(getBaseContext(),
"Artist Deleted", Toast.LENGTH_SHORT).show();
//refreshes list
adapter.notifyDataSetChanged();
//displays dialog box if no artists left
displayNoArtist();
}
@Override
public void onFailure(Throwable error) {
Log.e("DELETE", "AppData.delete Failure", error);
}
});
:
03-12 13:41:03.449: E/AndroidRuntime(18375): FATAL EXCEPTION: main
03-12 13:41:03.449: E/AndroidRuntime(18375): 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(2130968661, class android.widget.ListView) with Adapter(class com.example.chartviewer.LazyAdapter)]
내가 비동기 메서드 내에서 내용을 삭제 한 후 내 어댑터를 통지 내 코드의 세그먼트
mKinveyClient.appData("artistdata", ArtistData.class).get(myQuery, new
KinveyListCallback<ArtistData>() {
@Override
public void onSuccess(ArtistData[] result) {
Log.e("FETCHING", "Data fetched sucessfully");
for (ArtistData data : result) {
String name= data.getArtistname();
String imageurl = data.getArtisturl();
String id = data.getArtistid();
artistIds.add(id);
HashMap<String, String> hashMap = new HashMap<String, String>();
hashMap.put(TAG_NAME, name);
hashMap.put(TAG_IMAGEURL, imageurl);
addMyArtists(hashMap);
}
displayData();
}
@Override
public void onFailure(Throwable error) {
Log.e("FETCHING", "AppData.get by Query Failure", error);
}
});
어댑터 작성자 코드 :
list = (ListView)findViewById(R.id.artistlist);
adapter = new LazyAdapter(MyArtistsActivity.this,"artists", artistItemList);
list.setAdapter(adapter);
registerForContextMenu(list);
은 실제로 AsyncTack에서 업데이트를 호출하는 위치에 따라 다릅니다. onPostExecute 메서드 또는 doInBackground 메서드에서 호출하고 있습니까? UI 업데이트는 항상 onPostExecute 메서드를 통해 호출해야합니다. –
??? Kinvey를 절대 사용하지 않았습니다. 실제로 어댑터 내용을 어디에서 업데이트하고 있습니까? –
@ G.BlakeMeike 코드가 위에 추가되었습니다. – AndroidEnthusiast