Nic*_*k L 1 sorting android cursor
我正在为我的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)
fre*_*edw 10
而不是这样做:
..., "Phone.CONTACT_ID ASC");
Run Code Online (Sandbox Code Playgroud)
试试这个
..., Phone.CONTACT_ID + " ASC");
Run Code Online (Sandbox Code Playgroud)