AutoCompleteTextView 中的变音符号/国际字符
我有一个(数组)列表
Car
Something
Šibica
Čavao
Cavao
有没有办法“强制”AutoCompleteTextView,这样如果用户输入字母“c”
Car
Čavao
Cavao
,它就会显示标准字母和国际字母 >(C 和 Č/Ć、S 和 Š、Z 和 Ž、D 和 Đ)。
I have a (array) list
Car
Something
Šibica
Čavao
Cavao
Is there a way to "force" AutoCompleteTextView so if user type in letter "c" it would show
Car
Čavao
Cavao
so it would show standard letter and international letter (C and Č/Ć, S and Š, Z and Ž, D and Đ).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
使用此类作为ArrayAdapter(在本例中它用于 HR,但它可以用于任何角色)。
Use this class as an ArrayAdapter (in this case it's for HR but it can be for any character).
当您将字符串与用户输入进行比较时,您可能需要使用 Collator...
http://download.oracle.com/javase/1.5.0/docs/api/java/text/Collator.html
...调用 getInstance(),设置适当的强度,并使用比较或等于方法来查找与用户输入匹配的内容。
When you're comparing your strings to the users input, you might want to use a Collator...
http://download.oracle.com/javase/1.5.0/docs/api/java/text/Collator.html
...call getInstance(), set an appropriate strength, and use the compare or equals methods to find what matches the user input.
为了让人们的生活更轻松,您需要将以下内容添加到 @svenkapudija 的正确答案中,以实现法语口音字符兼容性。这是通过 Excel 在不到 40 秒内完成的
To make people's lives easier, here's what you need to add to the correct answer by @svenkapudija for French accented character compatibility. This was made via excel in less than 40 seconds
对于来自波兰的人;):
for people from poland ;):
svenkapudija 的答案很好......我使用它并稍加修改只是为了确保变音符号过滤器适用于第一个单词之外的其他单词
此外,这是针对来自捷克共和国的人;-)
svenkapudija's answer is good...I used it and modified slightly just to ensure that the diacritics filter would work for other than first word
Also, this is for people from Czech Republic ;-)
@svenkapudija 的优秀答案可以使用 java.text.Normalizer 推广到大多数拉丁脚本语言。在过滤器代码中,将: 替换
为:
@svenkapudija 's excellent answer can be generalized to most Latin script languages using
java.text.Normalizer
. In the filter code, replace:with:
如果您需要推出自己的解决方案,则应考虑使用 accent-folding ,一种将 Unicode 重音字符串转换为 ASCII 文本的技术。您可以生成数组中所有字符串的 ASCII 版本,并将用户的部分查询与该数组进行匹配。
If you need to roll your own solution, you should consider using accent-folding, a technique for transforming Unicode accented strings into ASCII text. You could generate ASCII versions of all the strings in your array and match the user's partial query against that array, instead.
对于斯洛伐克语:
For Slovak language: