Martin
Martin

Reputation: 650

Update EditText content without resetting input method state

Well, the title may sound complicated, but it's not. I just want to update EditText text without notifying the input method. I am using editText.setSelection(getCursor); but, for instance, if I am in special characters menu and I write something, keyboard jumps back to normal characters (a-z). Without setSelection I can continue in typing digits and special characters. Is there any workaround for this issue?

Upvotes: 0

Views: 185

Answers (1)

Daksh Gargas
Daksh Gargas

Reputation: 3923

What you want is to "restore the keyboard state (whether emoji or last selected language), but unfortunately that's NOT possible.

Is there any workaround for this issue?

Not really, but what you can do is prepare a custom emoji keyboard and open if programmatically. But this approach also has a loophole, you won't be able to track user's current selection of its keyboard. I mean you won't know whether user selected emojiKeyboard or normalKeyboard and you'll end up opening emojiKeyboard every-time. BUT what you can do is check the last input inside the editText by the user and then open your own emojiKeyboard but again, what is user switched his/her keyboard style?

[EDITED] (asnwers to questions from comments)

Why can't activity keep the keyboard state?

Because the keyboard developers didn't provide any callback as such, plus keyboard is some sort of third-party application which and can vary from devices to devices so it wasn't feasible

Also, what about spanning text using Editable instance. Will activity keep keyboard state if I will just span existing text?

NO Activity will just not keep the state

Upvotes: 1

Related Questions