小编Nic*_*k L的帖子

在Android中对Cursor进行排序以在SimpleCursorAdapter中使用

我正在为我的Android类做一个项目.该应用程序非常难看,并不是很有用,但它是为了证明我们可以实现内容提供商.我遇到的问题是对Cursor进行排序.这是我的代码:

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);
Run Code Online (Sandbox Code Playgroud)

sorting android cursor

1
推荐指数
1
解决办法
9382
查看次数

标签 统计

android ×1

cursor ×1

sorting ×1