Adapter.notifydatasetchanged Doesn't Work
Solution 1:
Try:
listViewChat.setAdapter(ChatAdapter);
You can replace the entire block with that. If the list is empty the adapter will be empty as well, and the listview will be refreshed with zero items.
Solution 2:
Please look at below code. You have to do similar to what I mentioned below. As I don't have your whole code snippet, so I modified the codes you mentioned:
ArrayList<MessageBubble> MessagesAll = new ArrayList<MessageBubble>();
ChatAdapter = new BubbleAdapter (this, MessagesAll);
listViewChat.setAdapter(ChatAdapter);
MessageBubble Messages = new MessageBubble();
Messages.setMessage("Hi");
if (Messages.Count != 0) {
MessagesAll.add(Messages);
ChatAdapter.notifyDataSetChanged();
}
Plase let me know if you still not succeeded.
Solution 3:
Use ChatAdapter.notifyDataSetInvalidated(); instead of ChatAdapter.notifyDataSetChanged();
Solution 4:
First and foremost, I would like to thank each and everyone of the contributors of stack. I'm sure I owe you more gratitude than I can give.
This question has taken way too much of my time. For the folks that are still looking for a solution:
the performFilter should remain as is.
the publishResults should be as simple as:
mIngredientList = (ArrayList) results.values; adapter.clear(); if (mIngredientList != null) { for (int i = 0; i < mIngredientList.size(); i++) adapter.add(mIngredientList.get(i)); }
the trick is this: public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
mIngredientAdapter.getFilter().filter(charSequence.toString()); mItemList.setAdapter(mIngredientAdapter); } Not re-adding the adapter, doesn't seem to work.
Post a Comment for "Adapter.notifydatasetchanged Doesn't Work"