Modify AutoCompleteTextView to show results with local special characters

泪湿孤枕 提交于 2019-12-12 04:58:14

问题


It was hard to write a proper topic for this issue. So, let me make myself clear.

I'm making a local app, dealing with data containing Turkish letters (ĞÜŞİÖÇğüşıöç). Problem is, the industrial tablet I must use don't have those chars on its virtual keyboard. So I need to have a special AutoCompleteTextView which treats some letters as same. For example if the client enters "sener" to the text box, "şener" should be shown as a result in the dropdown too. Is there even a way I could achieve that?


回答1:


You have a few choices. For example, when user type ozgur, show him the combinations of this word with turkish letters by replacing o with ö and u with ü. Something like that.

private char toTurkish(char c) {

    if(c == 'o')  return 'ö';
    if(c == 'u')  return 'ü';
    //...
}

private void usage() {

   String word = "ozgur";

   for(i = 0; i < word.length; i++) {

       word.setCharAt(i, toTurkish(word.charAt(i)));
   }

}

Or create a manual list that contains turkish words by adding turkish dictionary file to your app. Compare using Regex when user types.

Or create a layout above the keyboard and put the letters. I'd choose this way. No need for AutoCompleteTextView.



来源:https://stackoverflow.com/questions/33801067/modify-autocompletetextview-to-show-results-with-local-special-characters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!