SoftKeyboard.java , .
1- .
mQwertyKeyboard = new LatinKeyboard(this, R.xml.qwerty);
mPersianKeyboard = new LatinKeyboard(this, R.xml.persian);
2- OnCreateInputView , .
InputMethodSubtype subtype = mInputMethodManager.getCurrentInputMethodSubtype();
switch(subtype.getLocale()) {
case "fa_IR":
setLatinKeyboard(mPersianKeyboard);
break;
case "en_US":
setLatinKeyboard(mQwertyKeyboard);
break;
}
mPersianKeyboard, fa_IR. fa_IR method.xml.
<subtype
android:label="@string/label_subtype_generic"
android:icon="@drawable/icon_en_us"
android:imeSubtypeLocale="en_US"
android:imeSubtypeMode="keyboard" />
<subtype
android:label="@string/label_subtype_generic"
android:icon="@drawable/icon_en_gb"
android:imeSubtypeLocale="fa_IR"
android:imeSubtypeMode="keyboard" />
3- , , onCurrentInputMethodSubtypeChanged :
@Override
public void onCurrentInputMethodSubtypeChanged(InputMethodSubtype subtype) {
mInputView.setSubtypeOnSpaceKey(subtype);
switch(subtype.getLocale()) {
case "fa_IR":
setLatinKeyboard(mSymbolsKeyboard);
break;
case "en_US":
setLatinKeyboard(mQwertyKeyboard);
break;
};
}
. getLocale() API 24. getLanguageTag(). .