Modify AutoCompleteTextView to show results with l

2019-09-12 04:44发布

问题:

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.