Diacritics/international characters in AutoCompleteTextView

前端 未结 8 1929
耶瑟儿~
耶瑟儿~ 2021-02-15 17:02

I have a (array) list

Car
Something
Šibica
Čavao
Cavao

Is there a way to \"force\" AutoCompleteTextView so if user type in letter \"c\"

相关标签:
8条回答
  • 2021-02-15 17:30

    For Slovak language:

        original = original.replace("Á", "A");
        original = original.replace("Ä", "A");
        original = original.replace("Č", "C");
        original = original.replace("Ď", "D");
        original = original.replace("É", "E");
        original = original.replace("Í", "I");
        original = original.replace("Ĺ", "L");
        original = original.replace("Ľ", "L");
        original = original.replace("Ň", "N");
        original = original.replace("Ó", "O");
        original = original.replace("Ô", "O");
        original = original.replace("Ŕ", "R");
        original = original.replace("Š", "S");
        original = original.replace("Ť", "T");
        original = original.replace("Ú", "U");
        original = original.replace("Ý", "Y");
        original = original.replace("Ž", "Z");
    
        original = original.replace("á", "a");
        original = original.replace("ä", "a");
        original = original.replace("č", "c");
        original = original.replace("ď", "d");
        original = original.replace("é", "e");
        original = original.replace("í", "i");
        original = original.replace("ĺ", "l");
        original = original.replace("ľ", "l");
        original = original.replace("ň", "n");
        original = original.replace("ó", "o");
        original = original.replace("ô", "o");
        original = original.replace("ŕ", "r");
        original = original.replace("š", "s");
        original = original.replace("ť", "t");
        original = original.replace("ú", "u");
        original = original.replace("ý", "y");
        original = original.replace("ž", "z");
    
    0 讨论(0)
  • 2021-02-15 17:32

    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.

    0 讨论(0)
提交回复
热议问题