在 Android 中对 Cursor 进行排序以在 SimpleCursorAdapter 中使用
我正在为我的 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);
I'm doing a project for my Android class. The app is very ugly and not very useful, but it's to demonstrate that we can implement Content Providers. The problem I'm having is sorting the Cursor. Here is my code:
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
而不是这样做:
尝试这个
Instead of doing this:
try this