在Android中对要在SimpleCursorAdapter中使用的光标进行排序

在Android中对要在SimpleCursorAdapter中使用的光标进行排序,android,sorting,cursor,Android,Sorting,Cursor,我正在为我的Android课程做一个项目。这个应用程序很难看,也不是很有用,但它是为了证明我们可以实现内容提供商。我遇到的问题是对光标进行排序。这是我的密码: setContentView(R.layout.main); String[] projection = new String[] {Phone.CONTACT_ID, Phone.DISPLAY_NAME, Phone.NUMBER}; Cursor mCursor = this.getContentResolver().que

我正在为我的Android课程做一个项目。这个应用程序很难看,也不是很有用,但它是为了证明我们可以实现内容提供商。我遇到的问题是对光标进行排序。这是我的密码:

setContentView(R.layout.main);
String[] projection = new String[] {Phone.CONTACT_ID, Phone.DISPLAY_NAME, Phone.NUMBER};
    Cursor mCursor = this.getContentResolver().query(Phone.CONTENT_URI, projection , null, null, "Phone.CONTACT_ID ASC");
    startManagingCursor(mCursor);

    ListAdapter adapter = new SimpleCursorAdapter(
            this, // Context.
            R.layout.rows,
            mCursor,                                              
            new String[] {Phone.CONTACT_ID, Phone.DISPLAY_NAME, Phone.NUMBER}, 
            new int[] {R.id.text1, R.id.text2, R.id.text3});
    setListAdapter(adapter);
而不是这样做:

..., "Phone.CONTACT_ID ASC");
试试这个

..., Phone.CONTACT_ID + " ASC");
而不是这样做:

..., "Phone.CONTACT_ID ASC");
试试这个

..., Phone.CONTACT_ID + " ASC");

您需要先对列表进行排序,还是需要能够在列表视图显示后对其进行排序?您需要先对列表进行排序,还是需要能够在列表视图显示后对其进行排序?