我只想在我的 iOS/Android 应用程序中支持以下 ASCII 字符:
<!--
CharacterRegions control what letters are available in the font. Every
character from Start to End will be built and made available for drawing. The
default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
character set. The characters are ordered according to the Unicode standard.
See the documentation for more information.
-->
<CharacterRegions>
<CharacterRegion>
<Start> </Start>
<End>Ȁ</End>
</CharacterRegion>
<CharacterRegion>
<!-- Apostrophe 8217 -->
<Start>‘</Start>
<End>„</End>
</CharacterRegion>
<CharacterRegion>
<!-- Currency symbols -->
<Start>₠</Start>
<End>₺</End>
</CharacterRegion>
</CharacterRegions>
是否可以在我的应用程序中以某种方式禁用所有其他 ascii 字符,以便人们只能在我的应用程序中的软键盘上选择支持的字符?
我只想支持英语、西类牙语、意大利语、法语、德语和葡萄牙语字符,以及一些特殊字符,例如货币符号。我不希望有人可以使用亚洲字符。
如何避免人们使用我在文本框中支持的字符以外的其他字符?
是否可以禁用某些软键盘按钮,以便玩家无法使用它们,或者在玩家使用软键盘输入文本框字符后是否始终需要检查文本框字符是否受支持?
最佳答案
是的,这是可能的。您只需要一个 TextWatcher。
textField.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// Check to make sure the new text entered
// matches your requirements, otherwise,
// remove it from the text field.
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
});
关于c# - 如何避免人们使用我在文本框中支持的字符以外的其他字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58284111/