B4A Library [Class] xIME (Extended IME)

The xIME class is a direct replacement, or a class wrapper, for the existing IME soft keyboard library. Note that the xIME class can only be used from activities, not from within other classes or code modules.

To use the xIME object, download the attached xIME.bas class file and add it to your project using the Project / Use existing module menu option.

If you are upgrading an existing project from IME to xIME, find the
B4X:
Dim IME As IME
in your code and change it to
B4X:
Dim IME as xIME
Then find and change
B4X:
IME.Initialize("IME")
to
B4X:
IME.Initialize(Activity, "IME")
And ensure the Phone library is checked in the Libs tab.

If you are adding xIME to a new or existing project, please download the original IME library here and install it according to its directions. Then ensure both the IME and Phone libraries are checked in the Libs tab in the lower right corner of the Basic4android editor. Then, in Sub Globals section of your project code enter
B4X:
Dim IME as xIME
and add in Sub Activity_Create
B4X:
IME.Initialize(Activity, "IME")

One more thing: add this line to the manifest using the Manifest Editor in the Project menu
B4X:
SetActivityAttribute(main, android:windowSoftInputMode, adjustResize|stateHidden)
If using in a different activity, specify that activity name instead of 'main' above. This will instruct android to continue processing the soft keyboard IME events if the app is paused and then resumed.

Three new properties are ScreenHeight, Visible and HardwareKeyboard.

ScreenHeight returns the height of the usable portion of the screen above the soft keyboard. This can be called at any time after the xIME object has been initialized.

Visible returns True if the soft keyboard is popped up and visible, otherwise it returns False if it is hidden.

HardwareKeyboard returns True if a hardware keyboard is present on the device, otherwise it returns False. (Thanks to Stevel05 for this additional code :sign0188:)

That's it. All the pre-existing IME methods and events are simply passed through to the underlying IME object. Please refer to the IME tutorial for help in using the other IME methods and for general IME help and guidance.

v1.00 - Initial release
v1.01 - Added Phone.HideKeyboard and set ScreenHeight in Initialize sub.
 

Attachments

  • xIME_Example.zip
    8 KB · Views: 361
  • xIME.bas
    4.3 KB · Views: 332
Last edited:

JesseW

Active Member
Licensed User
Longtime User
Version 1.01 is updated in the first post, and the message text has been revised to better reflect the class. Enjoy :)
 
Top