2

I'm trying to convince an EditText-view to only use the SoftKeyboard that I wrote. It's bugging me for a few days already and I can't believe that this isn't possible to do. I might not see the obvious...

So far I managed to write my own SoftKeyboard based on the sample that comes with the Android SDK. I'm able to manually select it as the input method (long click, input method, *pick*). The SoftKeyboard then works fine and does everything I want. I also cleaned up the context menu to disallow changing the input method (obviously I currently needed it to be in the menu otherwise I wouldn't be able to choose my SoftKeyboard).

In other words the only thing left is to tie the SoftKeyboard to the EditText.

I noticed the bunch of ime*-attributes on the EditText, but they don't seem to be useful for my problem as I don't want to change anything about the action key. inputMethod requires a KeyListener, which the SoftKeyboard is not (I tried to make it one, but there seems to be a problem with the class-loader as it wouldn't find my class => ClassNotFoundException).

Can anyone please point me to some useful information?

2 Answers 2

3

I'm currently reinventing my approach and try to work without the InputMethodService. I keep the sample code as a reference for handling the user input. Basically it should just be a simple view that pops up when needed.

After further research I found a really helpful question about an App-specific soft-keyboard. If you run into my situation, look there.

1

I can't believe that this isn't possible to do

What I suspect that you wrote was an input method editor, based on your "manually select it" note. This is a global construct, available for the user to elect to install and use if desired. And your input method editor could be used, at the user's discretion, in any application in the device.

You, in your application code, cannot mandate a particular input method editor, whether you wrote it or not.

What you could do, perhaps, is arrange to use the same UI from your input method editor as some sort of pop-up in your activity. For example, KeyboardView, according to Ms. Hackborn, is a standard View and can be used like any other. The user could tap a button next to your EditText to display your keyboard UI (e.g., animated slide up from the bottom of the screen), or something like that.

I also cleaned up the context menu to disallow changing the input method

Please allow the user to choose the input method, or do not use an EditText.

4
  • Yes, you understood my problem. I don't want to let the user change the input method as the app has additional logic to the pressed keys. The user is well aware of this (nothing illegal anyway).As a matter of fact I wouldn't want the input method to be available for any other EditText other than mine as that would cause a lot of problems otherwise. Basically I'll need to find out if my app has the focus and show a dialogue if not. Good point! I'll also look into forcing my UI to appear on a tap.
    – sjngm
    Oct 22, 2010 at 5:19
  • @sjngm: "As a matter of fact I wouldn't want the input method to be available for any other EditText other than mine as that would cause a lot of problems otherwise." -- definitely not a good role for input method service, then. You might still be able to use KeyboardView, though. Oct 22, 2010 at 10:58
  • @cw: Right. I'm currently trying to get the keyboard on the screen. However, I'm failing miserably right there (this is my first Android-project anyway...). The sample SoftKeyboard uses a class subclassed from KeyboardView. I just hope that once I got that on the screen the rest works "automatically". I have the keyboard in the layout, but the input field has to be full-screen. The keyboard has to pop-up somehow...
    – sjngm
    Oct 27, 2010 at 10:32
  • the problem with the embedded view is that it does not behave like a keyboard service. No sort input mode (pan or resize) available, and the view is in the same window (not good for dialogs with padded window background)
    – njzk2
    Apr 6, 2016 at 19:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.