1
正在關注this tutorial我已經創建了一個完全可用的Android OS鍵盤。它是一個標準的QWERTY字母/數字。Android自定義鍵盤 - 如何檢測請求的鍵盤類型
我有數字鍵盤的第二個鍵盤標記。
似乎我無法檢測是正在由文本輸入框中指定什麼類型的鍵盤。 edittext指定的類型爲 editText.setInputType(InputType.TYPE_CLASS_TEXT);
但我的IME服務如何檢測到這一點,以便它可以呈現正確的鍵盤?
public class MyKeybdIME extends InputMethodService implements KeyboardView.OnKeyboardActionListener {
private KeyboardView kv;
private Keyboard keyboard;
private Keyboard numboard;
private boolean caps = false;
@Override
public View onCreateInputView() {
kv = (MKeyboardView)getLayoutInflater().inflate(R.layout.keyboard, null);
keyboard = new Keyboard(this, R.xml.qwertyfull);
numboard = new Keyboard(this, R.xml.num);
// InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
//How can you detect what is being asked for?
// imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
// Or am I on the wrong path for this part?
kv.setKeyboard(keyboard);//... Or numboard when the entry requests a numeric keyboard
kv.setOnKeyboardActionListener(this);
return kv;
}