IME (Input Method) の標準的な実装を提供するクラスです。
public class MyInputMethodService extends InputMethodService
implements KeyboardView.OnKeyboardActionListener {
private KeyboardView keyboardView;
private Keyboard keyboard;
@Override
public void onInitializeInterface() {
// キーボードのレイアウト ファイルを読み込み Keyboardを生成する
keyboard = new Keyboard(this, R.xml.keyboardLayoutFile);
}
@Override
public View onCreateInputView() {
// KeyboardView用のレイアウト リソースからレイアウトを追加し、そのレイアウトの親要素をKeyboardViewとして取得する
keyboardView = (KeyboardView) getLayoutInflater().inflate(R.layout.keyboard, null);
keyboardView.setOnKeyboardActionListener(this);
// KeyboardViewに Keyboardを結びつける
keyboardView.setKeyboard(keyboard);
return keyboardView;
}
}