How to open a keyboard on a button, click in android?

How can I open the keyboard when I press a button on Android?

I want to be like this:

enter image description here

+6
source share
3 answers

Please, try

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0); 
+21
source
 InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(view, flags) 

could be an example:

 InputMethodManager imm = (InputMethodManager) RouteMapActivity.this .getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(mapView, InputMethodManager.SHOW_IMPLICIT); 
+7
source

Write this code inside the button press event for the TOGGLE keyboard:

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

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


All Articles