From e69aa492bd3ebaf848c4dfddafd6dfb045c40648 Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Thu, 9 Feb 2012 09:31:03 -0500 Subject: [PATCH] Fixed Bug java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification Change-Id: I7618beebfcac228eeba704d9d7b9e985b4ceeb86 Signed-off-by: Ricky Barrette --- .../android/ExaltedDice/ExaltedDice.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/ExaltedDice/src/com/TwentyCode/android/ExaltedDice/ExaltedDice.java b/ExaltedDice/src/com/TwentyCode/android/ExaltedDice/ExaltedDice.java index 0c85291..abd67c2 100755 --- a/ExaltedDice/src/com/TwentyCode/android/ExaltedDice/ExaltedDice.java +++ b/ExaltedDice/src/com/TwentyCode/android/ExaltedDice/ExaltedDice.java @@ -70,15 +70,6 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic } } - /** - * clears the rollHistory List array and refreshes the listview - * @author ricky barrette - */ - private void clearHistory() { - mDb.clearHistory(mGameId); - refresh(); - } - /** * also implemented OnClickListener * @@ -219,7 +210,7 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic quitDialog(); return true; case MENU_CLEAR: - clearHistory(); + mDb.clearHistory(mGameId); return true; case SETTINGS: startActivity(new Intent(this, Settings.class).putExtras(getIntent().getExtras())); @@ -346,8 +337,13 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic * @author ricky barrette */ public void refresh(){ -// mListAdapter.notifyDataSetChanged(); - mListView.setAdapter(mListAdapter); + mListAdapter.notifyDataSetChanged(); + mListView.post(new Runnable(){ + @Override + public void run(){ + mListView.setAdapter(mListAdapter); + } + }); } /** @@ -482,8 +478,12 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic @Override public void onDeletionComplete() { - // do nothing - + this.runOnUiThread(new Runnable(){ + @Override + public void run(){ + refresh(); + } + }); } @Override