How to use the Android soft keyboard in SurfaceView

I have a SurfaceView that I draw on, there are no controls, text fields, or any other type of form type element. I would like to be able to:

1: tap one of the circles that I draw with the SurfaceView onDraw () method and open the standard Android soft keyboard. (I know how to make the touch detection part, I just need to open the soft keyboard somehow)

2: When I type, I want the letters that I selected to appear on the canvas (again I know how to make part of the drawing, but how can I capture the keys that the user selected in the first place?)

many tanks

David

+4
source share
1 answer

you can try this to show the keyboard:

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0); 

if this shows this for you, I assume that you could listen for key events by overriding the onKeyDown () method of your activity

+2
source

Source: https://habr.com/ru/post/1400051/


All Articles