如何在Android中以编程方式禁用表情符号 [英] How to disable emojis programmatically in Android
本文介绍了如何在Android中以编程方式禁用表情符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想以编程方式隐藏键盘上的表情符号和自动建议.它可以在某些Android设备上运行,但不能在所有设备上运行.这是隐藏自动建议的代码:
I want to hide emojis and auto suggestions from keyboard programmatically. Its working in some Android devices but not in all devices. here's my code for hide auto suggestions:
txtSingupemail.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
|InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
txtSignuppwd.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER | InputType.TYPE_TEXT_VARIATION_PASSWORD);
txtSignuppwd.setTransformationMethod(PasswordTransformationMethod.getInstance());
以下是我的用户界面的快照:
这是用户单击登录"按钮时的布局.当用户点击标记为红色的左下图标时,由于表情符号的建议,键盘高度会增加.
This is layout when user clicks signIn button. When user tap on bottom left icon which is marked red, the keyboard height goes increase due to emojis as suggestions.
请参见以下快照:
有什么办法可以通过编程从键盘上隐藏那些顶级表情符号?
Is there any way to hide those top emojis from keyboard programmatically?
推荐答案
尝试一下对我有用
editText.setFilters(new InputFilter[]{new EmojiExcludeFilter()});
private class EmojiExcludeFilter implements InputFilter {
@Override
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
for (int i = start; i < end; i++) {
int type = Character.getType(source.charAt(i));
if (type == Character.SURROGATE || type == Character.OTHER_SYMBOL) {
return "";
}
}
return null;
}
}
这篇关于如何在Android中以编程方式禁用表情符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文