11

Assume there is a character' 暂' that I want to write using a custom Android IME. If I want to show the said glyph when I press the key "G" followed by "E", how do I go about it (G itself is assigned to another code).

I know I can assign many characters to the same label as follows and I will get different results based on the frequency of clicks using...

<Key android:codes="xx,yy" android:keyLabel="暂"/>

My goal is similar but some how different. I was hoping that I may be able to get the desired effect by doing something like ....

<Key android:codes="xx,xx+zz=yy" android:keyLabel="暂"/>

But that doesn't seem to be valid way of doing it.

Andromeda
  • 1,370
  • 2
  • 10
  • 15

1 Answers1

2

You can't do this in XML, however, it can be done programmatically. You could overwrite the onKey listener (of a particular view or create a full new InputType) and use it to keep track of previous inputs. In case the listener finds that an "E" is preceded by a "G", for example, the output would be the key you specified. Here you find an implementation.

kalabalik
  • 3,792
  • 2
  • 21
  • 50