Yog*_*uru 10
获取解决方案以更改自定义键盘的布局.
键盘第一次加载onCreateInputView()时调用.之后当键盘打开onStartInputView(EditorInfo属性,布尔重启)时每次调用.
所以,现在键盘(Theme)的布局必须在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;
}
Run Code Online (Sandbox Code Playgroud)
并在onStartInputView中执行此操作
public void onStartInputView(EditorInfo attribute, boolean restarting) {
super.onStartInputView(attribute, restarting);
setInputView(onCreateInputView());
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2589 次 |
| 最近记录: |