如何在软键盘中添加拼写检查器?

时间:2017-11-29 13:18:46

标签: android-layout keyboard

我正在使用Latin IME创建自定义键盘。是否可以在拉丁键盘中添加拼写检查栏?

1 个答案:

答案 0 :(得分:0)

你必须尝试这样

您需要将此权限添加到清单中:

<uses-permission android:name="android.permission.WRITE_USER_DICTIONARY"/>

在java代码中

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {  
    UserDictionary.Words.addWord(this, "MadeUpWord", 10, "Mad", Locale.getDefault());
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.CUPCAKE) {
    UserDictionary.Words.addWord(this, "MadeUpWord", 10, UserDictionary.Words.LOCALE_TYPE_CURRENT);
}

了解更多信息:https://developer.android.com/reference/android/provider/UserDictionary.Words.html