I am working on create custom keyboard. I got such a good and useful demo for that from Here. I want to create multiple theme of keyboard, so i create another layout for keyboard, but now problem is i don't know how to set the layout of current keyboard or have to load keyboard newly or have to do something else.. to change the design of keyboard don't have any Idea.
My concept is user have to choose the keyboard theme from activity and the keyboard design will change.
Can anybody help me or have any idea to push this problem out..?
Get solution to change the layout of custom keyboard.
When keyboard first time load onCreateInputView() is called. After that when keyboard open onStartInputView(EditorInfo attribute, boolean restarting) called every time.
So, now layout of keyboard(Theme) have to define in onCreateInputView() Like This
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;
}
and do this in onStartInputView
public void onStartInputView(EditorInfo attribute, boolean restarting) {
super.onStartInputView(attribute, restarting);
setInputView(onCreateInputView());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With