android app specific soft keyboard
Asked Answered
H

2

19

Is there a way to create an app specific soft keyboard on Android? After reading about InputMethodService docs and checking out alternative keyboard apps out there, I figure the alternate keyboard can only be configured for system wide usage (through Settings -> Locale and Text).

If the answer to above question is no, then is there at least a way to load a custom dictionary and override the default dictionary of the system keyboard (only when my app is in use)? That will help in giving very relevant suggestions to the user when he has only tapped couple of keys.

Hakan answered 13/12, 2009 at 16:19 Comment(0)
P
21

If you just want a View that looks and acts like a soft keyboard, I did that in my SmallKeyboard class. You just need to extend android.inputmethodservice.KeyboardView and decide on layout. See the onKey and onText methods at the end of that file for the action taken when keys are pressed.

Instead of my keyboard model inner class, you could load it from XML if your key set is fairly constant.

Pith answered 22/12, 2009 at 16:12 Comment(7)
That looks useful. I installed SGTPuzzles to see how the keyboard works, but I couldn't get it on screen. I only get the redo/undo buttons. Which puzzle will popup the instance of SmallKeyboard? Thanks.Hakan
The undo/redo buttons are actually such an instance, but more interesting instances can be seen in puzzles where number entry is required: Filling, Solo, Unequal (and coming soon, Keen and Towers). Also Guess and Map have minimal extra buttons.Pith
The question wasn't answered in full. How do you tell your application to use this custom keyboard?Consensual
You don't tell it to use this keyboard. It's a view, so you treat it as any other normal view.Gaberdine
my SmallKeyboard class link is now 404.Teleost
Its 404 again. And I didnt quite get the answer to the question, how to get this keyboard to popup instead of the system keyboard? I get that its just view like any other view. But when the focus is put on an edit text, how to get this keyboard to popup instead of the system keyboard?Cyano
@GregEnnis Link fixed. As for disabling the built-in keyboard on an EditText, it looks like you could try developer.android.com/reference/android/widget/… with TYPE_NULL but I haven't tested that.Pith
T
9

The Android Nethack application has a complete and clear source code example of how to create a custom keyboard for an application, how to display it on screen and how to define multiple keyboard layouts. It contains pretty much everything you need to know.

It is by far the best example I have seen.

http://code.google.com/p/nethack-android/

Timberwork answered 5/1, 2012 at 18:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.