views:

23

answers:

2

Hi,

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?

A: 

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.

CommonsWare
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
@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.
CommonsWare
@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