Reputation: 1564
I'm creating an object from the android Keyboard class (https://developer.android.com/reference/android/inputmethodservice/Keyboard.html). In my case I just need the default keyboard, no custom keyboard. But the constructors of the Keyboard class requires a xml resource file that contains a definition of rows and keys. It seems it's only for creating a custom keyboard.
I need that object of the Keyboard class to use it in a KeyboardView within a TabLayout:
keyboard123 = (KeyboardView) Tab2View.findViewById(R.id.keyboard123);
Keyboard k1 = new Keyboard(Tab2View.getContext(), R.xml.qwerty_keyboard);
k1 = new Keyboard(Tab2View.getContext(), com.android.internal.R.id.keyboardView);
keyboard123.setKeyboard(k1);
The code above works great, but only if I create an xml file "qwerty_keyboard" with key definition. Is there a way to just get the android default keyboard and display it in one of the tabs in the TabLyout?
Upvotes: 3
Views: 1932
Reputation: 28162
You can't do it the way you are trying to do it. You can't make the default keyboard in a View because it's a separate app that runs by itself.
So in order to achieve what you are trying to you'll need to request the inputmanager to pop up when you go to keyboard tab but frankly you'll have so many issues with the sizing (height) that I won't recommend this kind of design :) Just think about it, everyone can make a keyboard and everyone can install one, there is many many many keyboards and they all have different heights, but you might be able to get that height and do some magic...
Another alternative would simply be to make your own embedded keyboard (kinda like what you already did).
Upvotes: 3