有没有办法在安卓系统中检测到德国的Umlauts?

问题描述 投票:5回答:1

我正在尝试用软键盘检测德文的umlauts。为了识别输入的字符,我使用了以下方法 onKeyUp(). 但这种方法对德国的乌拉乌斯不执行。

有什么方法可以让我识别它们?

android android-keypad
1个回答
2
投票

一般情况下,检查语言特定字符的方法并不是一个好主意。KeyListener. 对于这种用例,最好使用 TextWatcher.

object : TextWatcher {

    override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
        val umlaut = "\u00FC"
        if (!s.isNullOrEmpty() && s[count - 1].toString() == umlaut) {
            // Do your thing
        }
    }

    ... 
}
© www.soinside.com 2019 - 2024. All rights reserved.