【发布时间】:2011-03-02 09:47:54
【问题描述】:
我正在为我的 Android 课程做一个项目。该应用程序非常丑陋,也不是很有用,但它是为了证明我们可以实现 Content Providers。我遇到的问题是对光标进行排序。这是我的代码:
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);
【问题讨论】:
-
您需要先对列表进行排序,还是需要在列表视图显示后才能对其进行排序?