假设我有两个具有相同布局的文本字段,例如(地址),第一个输入要求地址为英文,键盘应默认显示为英文,第二个输入要求地址为阿拉伯语
我的问题是:我是否可以在需要时使用特定语言显示键盘,例如阿拉伯语地址。
语言有android:inputType""
吗?
答案 0 :(得分:6)
是的,您可以通过实施以下权限将您的应用声明为系统应用来实现这一目标:
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
从以下
获取当前的键盘输入语言IDSettings.Secure.getString(getContentResolver(),Settings.Secure.DEFAULT_INPUT_METHOD)
然后,您需要使用以下代码将键盘输入显式设置为所需的语言:
InputMethodManager imeManager = (InputMethodManager) getApplicationContext().getSystemService(INPUT_METHOD_SERVICE);
//imeManager.showInputMethodPicker(); //This is to see available keyboards.
imeManager.setInputMethod(null,"jp.co.omronsoft.openwnn/.OpenWnnJAJP");
答案 1 :(得分:0)
你有一个关于如何做到这一点的大工作 - 这是创建你自己的键盘,为此你必须知道你正在寻找的键盘。 (这将与常规键盘完全相同)
在这里,您可以获得一些样本here&amp; code samples。
How to make an Android custom keyboard?
按照此链接制作自定义键盘最后
EditText editText = (EditText) findViewById(R.id.editText);
MyKeyboard keyboard = (MyKeyboard) findViewById(R.id.keyboard);
// prevent system keyboard from appearing when EditText is tapped
editText.setRawInputType(InputType.TYPE_CLASS_TEXT);
editText.setTextIsSelectable(true);
// pass the InputConnection from the EditText to the keyboard
InputConnection ic = editText.onCreateInputConnection(new EditorInfo());
keyboard.setInputConnection(ic);