How to use android soft keyboard in SurfaceView
-
08-12-2019 - |
Question
I have a SurfaceView that I draw onto, there are no controls, text boxes or any other sort of form-type item. I would like to be able to :
1: Touch one of the circles I draw on the SurfaceView onDraw() method and open the default android soft keyboard. (I know how to do the touch detection part, just need to open the soft keyboard somehow)
2: As I type I want the letters I select to be shown on the canvas (Again I know how to do the drawing part, but how do I capture the keys the user has selected in the first place?)
many tanks
David
Solution
you can try this to show the keyboard:
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
if that shows it for you then I imagine you could listen for the key events by overriding the onKeyDown() method of your activity
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow