根据 android 中的设备区域设置禁用逗号或点

Disable comma or dot based on device locale in android

如何根据设备上选择的语言环境禁用 android 中的点 (.) 键或逗号 (,) 键。 我需要对英语使用点,对瑞典语或其他支持逗号而不是点的语言使用逗号。

您可以使用 Android 中的 DigitsKeyListener

例如,

如果是英文,

editText.setKeyListener(DigitsKeyListener.getInstance("abcdefghijklmnopqrstuvwxyz1234567890."));

如果是瑞典语,

editText.setKeyListener(DigitsKeyListener.getInstance("abcdefghijklmnopqrstuvwxyz1234567890,"));

Note that this EditText will only accepts the characters you specified in this String. So whatever chars you want you have to add it to here.