Android 联系人:本地化排序规则/排序不正确
这是我的问题:我正在编写一个替代联系人应用程序,该应用程序指定用于处理很多不同的语言和字母。当用我自己的语言瑞典语查询名称时,使用元音变音字符的名称对我来说以不合逻辑的方式排序,但对 unicode 来说是合乎逻辑的,我想:
应该是/瑞典风格:A,B,C,...,Z,Å 、 、 、 。
查询结果:A, Å, Ä, B, ..., N, O, Ö, P, ...
我认为这在任何偏离拉丁字母的语言中都会出现问题。我所做的所有测试都是在模拟器上进行的。我的开发小组正在对框架进行更改,因此也欢迎低级答案。
Uri uri = ContactsContract.Contacts.CONTENT_URI;
String[] projection = new String[] {
ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.Contacts.PHOTO_ID
};
String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '1'";
String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC";
mCursor = managedQuery(uri, projection, null, null, sortOrder);
更新:我们目前正在研究此轨道:对字符串数组进行排序,待定。 .. 我还将其添加为 Google Code 上的问题。
this is my problem: I'm writing an alternative contacts app which is specified to work with A LOT of different languages and alphabets. When querying names in my own language, Swedish, the names using umlaut characters are sorted in an illogical manner to me, but logical to unicode i suppose:
Should be/Swedish style: A, B, C, ..., Z, Å, Ä, Ö.
Query result: A, Å, Ä, B, ..., N, O, Ö, P, ...
I assume this will be a problem in any language that deviates from the latin alphabet. All tests I've made are on the emulator. My dev group are making changes to the framework so low-level answers are welcome as well.
Uri uri = ContactsContract.Contacts.CONTENT_URI;
String[] projection = new String[] {
ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.Contacts.PHOTO_ID
};
String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '1'";
String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC";
mCursor = managedQuery(uri, projection, null, null, sortOrder);
Update: we're currently investigating this track: Sort a String array, TBC...
I also added it as an issue on Google Code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嘎啊。看起来是这样的:
在 vanilla Java (SE-1.6) 中运行以下代码会生成所需的输出:
但在 Android 中相同的代码对我不起作用。
编辑:我在 Android Google 上为此提出了一个问题代码站点,已被审稿人评论。
Gaah. It appears it's like this:
running the following code in vanilla Java (SE-1.6) generates the desired output:
But the very same code in Android does NOT work for me.
Edit: I made an issue out of this on the Android Google Code site, it's been commented by a reviewer.