Im trying to create an IME for android that is not a traditional keyboard (rows of keys corresponding to the different letters) and I am having trouble finding helpful resources on how to do so since all of the code examples in the SDK use a Keyboard API and it’s built in functions.
I’ve designed the interface of the IME in an XML file as though it were simply an Activity within in application but I’m getting lost in their demos since their Keyboards are simply objects that are built from a different style of XML structure.
If anyone has a link to an open source project that does not use the tradional keyboard structure or could simply guide me to displaying the UI that I’ve already constructed onto the IME window, I think I can figure the rest out.
If you need any more specfic information, please feel free to ask.
Thanks in advance.
The SoftKeyboard sample is in fact structured similarly to what you need, though you don’t know it. Let’s break it down — here’s a complete stub to act as an input method service and use the standard XML keyboard:
Note that two XML documents are named. The first,
res/xml/qwerty.xml, defines the layout so that theKeyboardViewclass knows how to draw the keyboard.But the layout which it inflates,
res/layout/input.xml, consists of this (simplified):This is all you need to declaratively create a view! Creating a stand-alone
Viewisn’t much different from creating anActivity. You don’t have the standard activity lifecycle, but both environments give you access to XML layouts. All you need to do is use the inflater, reference any subviews you need, and then return the main view.So hopefully you’ll be able to inflate your layout after thinking about this.
You don’t even need to use XML layouts if your layout is simple enough. If your input method can consist entirely of a single view, you can just instantiate it directly in
onCreateInputView. Here’s a complete stub input method service that doesn’t use any XML:(Of course the boilerplate in the manifest and
res/xml/method.xmlfiles would still be there.)