【问题标题】:Android : Contact List is not by all case of LettersAndroid:联系人列表并非都是字母
【发布时间】:2015-12-08 05:55:40
【问题描述】:

我正在尝试按排序顺序获取所有 Contact 列表。我正在获取所有联系人列表,但它的第一个排序名称以 大写(ABCD..) 开头,在对所有名称以大写字母开头进行排序后,只有它开始排序以开头的剩余名称小写字母(a,b,c....)

private static final String[] PROJECTION = new String[] {
        ContactsContract.CommonDataKinds.Phone.CONTACT_ID,
        ContactsContract.Contacts.DISPLAY_NAME,
        ContactsContract.CommonDataKinds.Phone.NUMBER
};

ContentResolver cr = getContentResolver();
    Cursor cursor = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, PROJECTION,
      null, null, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + " ASC");

if (cursor != null) {
        try {
            final int nameIndex = 
                     cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME);
                   nameContact = cursor.getString(nameIndex);
    finally {
            cursor.close();
           }

这里的名称是作为一个单独的两个列表排序的。首先排序所有名称以大写开头,然后排序名称以小写开头。

谁能告诉我如何解决这个问题?

提前致谢:)

【问题讨论】:

    标签: android android-contentprovider android-contacts android-contentresolver


    【解决方案1】:

    将这样的查询与 collat​​e 一起使用。

    Cursor cursor = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, PROJECTION,
      null, null, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + " COLLATE NOCASE ASC");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多