【问题标题】:is there a way to detect German Umlauts in Android有没有办法在 Android 中检测德国元音变音
【发布时间】:2020-10-04 15:03:58
【问题描述】:

我正在尝试使用软键盘检测德语变音符号。为了识别输入的字符,我使用方法onKeyUp()。但是这种方法不适用于德语变音符号。

有没有办法让我认出他们?

【问题讨论】:

    标签: android android-keypad


    【解决方案1】:

    一般来说,使用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
            }
        }
    
        ... 
    }
    

    【讨论】:

      猜你喜欢
      • 2023-04-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-23
      相关资源
      最近更新 更多