我正在尝试使用 LoaderCallbacks 创建一个 Listview 我能够看到列表中的所有元素。但是现在我想对其进行排序,以便数据库中的最新项目是顶部的第一个项目。我在数据库中有一个名为 COLUMN_MESSAGE_DATE 的 Coulmn,其中包含一个时间戳,我希望最新的行位于顶部。在 onCreateLoader 中,当我返回加载程序时,我按此 Coulmn 排序,但最新的行仍位于底部... . 我错过了什么吗?
public class MessageListFragment extends Fragment implements LoaderCallbacks<Cursor>{
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args)
{
// Create the Cursor that will take care of the data being displayed
Log.d("TAG", "onCreateLoader...");
return new CursorLoader(getActivity(),CONTENT_URI, null, null, null,DataBase.COLUMN_MESSAGE_DATE);//I thought this should sort the list by date...
}
@Override
public void onLoadFinished(Loader<Cursor> arg0, Cursor cursor)
{
// Now Bind the data to the View
Log.d("TAG", "onLoadFinished...ARG1= " + cursor);
mCusrorAdapter = new CustomCursorAdapter(getActivity(), cursor);
mListView.setAdapter(mCusrorAdapter);
}
}