カスタム キーボードのレイアウトを変更するソリューションを取得します。
キーボードの初回ロード時に onCreateInputView() が呼び出されます。その後、キーボードを開くと onStartInputView(EditorInfo 属性、ブール値の再起動) が毎回呼び出されます。
したがって、キーボード(テーマ)のレイアウトは onCreateInputView() で定義する必要があります
public KeyboardView mInputView;
public View onCreateInputView() {
SharedPreferences pre = getSharedPreferences("test", 1);
int theme = pre.getInt("theme", 1);
if(theme == 1)
{
this.mInputView = (KeyboardView) this.getLayoutInflater().inflate(R.layout.input, null);
}else
{
this.mInputView = (KeyboardView) this.getLayoutInflater().inflate(R.layout.input_2, null);
}
this.mInputView.setOnKeyboardActionListener(this);
this.mInputView.setKeyboard(this.mQwertyKeyboard);
return this.mInputView;
}
onStartInputViewでこれを行います
public void onStartInputView(EditorInfo attribute, boolean restarting) {
super.onStartInputView(attribute, restarting);
setInputView(onCreateInputView());
}