Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I update the editor action button display on the fly?

My question is: How can I update the display of the action button of the soft keyboard on the fly?

Another post seems to be about changing the editor action BEFORE the keyboard is shown: Android: Can't figure how to use setImeActionLabel. I would like to change the soft keyboard action button WHILE it is shown.

I have partially succeeded: - I can change the action by using: editText.setImeOptions(EditorInfo.IME_ACTION_GO); - I can also redraw the keyboard using: InputMethodManager.restartInput(editText); I do this using TextWatcher.afterTextChanged. - However, I have a problem with this. If I press a key, on top of that the keyboard shows which key has been pressed. But when I call restartInput(...), this also hides the view that shows which key has been pressed. This seems normal behaviour to me, but I need a way around it.

Extending EditText and overriding onKeyUp is not a good idea, see: https://groups.google.com/forum/?fromgroups#!topic/android-developers/RIxGfx5qOjM.

The KeyboardView class has exactly what I need (invalidateKey), but I think that is only accessible when you create your own input method.

Anybody else have some better ideas?

like image 453
a2ronus Avatar asked Jan 06 '11 23:01

a2ronus


2 Answers

Please try to be more specific when you describe what do you want to do ... I needed to read your post many times to be able to understand your request ..

So what you want to do is how to react to any key pressed on keyboard and show info about it in action key on keyboard. If that is not your target plz to explain more...

If yes, so I guess you would need to use additionaL EditText ( not visible ) lets call et0. after finishing inserting a letter or any pattern you define through ontextchanged in your edit text, change the focus to et0.. so you can change the actionKey.. and then send the focus back to your editText .. so you can thread or timertask, or any way to manage this temporary changing of focus into and from et0 .. here its not necessary to restart the input.

hope that will help you ..

like image 195
Maher Abuthraa Avatar answered Sep 18 '22 22:09

Maher Abuthraa


Have you tried changing /system/usr/keychars/default.kcm on-the-fly before invoking your redraw code? (filename might be different depending on version of Android).

There, you are allowed to set not only key output characters, but also key display values. I haven't tried it, it might also incur a delay, but it's worth a try.

like image 1
Alex Avatar answered Sep 22 '22 22:09

Alex