How to use Android soft keyboard in SurfaceView

I have a SurfaceView that I draw, without controls, text boxes or any other types of form type items. I want to be able to:

1: Touch I drew a circle on the SurfaceView onDraw() method, and then opened the default android soft keyboard. (I know how to do the touch detection part, only need to open the soft keyboard in a certain way)

2: When When I type, I want the letters I selected to be displayed on the canvas (I know how to draw the part again, but how do I capture the key that the user selected first?)

A lot of tanks

David

You can try this to show the keyboard:

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

If it shows to you, then I miss you You can listen to key events by overriding the onKeyDown() method of your activity

I have a SurfaceView that I draw, no controls, text boxes or any other type of form Item. I want to be able to:

1: Touch a circle I drew on the SurfaceView onDraw() method, and then open the default android soft keyboard. (I know how to do the touch detection part, only The soft keyboard needs to be opened in some way)

2: When I type, I want the letters I selected to be displayed on the canvas (I know how to draw the part again, but how do I capture the key that the user selected first? )

Many tanks

David

You can try this to show the keyboard:

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

If it is shown to you, then I think you can listen to key events by overriding the onKeyDown() method of your activity

Leave a Comment

Your email address will not be published.