如何強制陣列適配器自行排序。 notifyDataSetChanged不起作用。我想要做的是將一個項目添加到數組adpater,然後強制它再次排序。 這是我的前列腺:在添加項目之後對陣列適配器排序
this.noteListViewAdapter = new NoteListViewAdapter(this.GetActivityContext(), R.layout.list_view_note_item, noteItems);
// sorting
this.noteListViewAdapter.sort(new Comparator<NoteItem>()
{
@Override
public int compare(NoteItem item1, NoteItem item2)
{
// TODO Auto-generated method stub
return item2.CreationDate.compareTo(item1.CreationDate);
};
});
它工作正常。項目被排序。但是,當我想添加新項目時,排序不起作用。它甚至沒有叫。 這是我如何添加新項目:
this.noteListViewAdapter.add(note);
this.noteListViewAdapter.notifyDataSetChanged();
謝謝您的幫助
排序再次notifyDataSetChanged之前之後添加()(); – wtsang02 2013-03-02 16:15:54