How to open Keyboard on Button click in android?

后端 未结 3 479
孤城傲影
孤城傲影 2021-01-12 02:12

How can I open Keyboard on Button click in android?

What I want to be like this:

\"enter

相关标签:
3条回答
  • 2021-01-12 02:45

    Please try this

    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
    
    0 讨论(0)
  • 2021-01-12 02:56

    Write this code inside the Button click event to TOGGLE the keyboard:

    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
    
    0 讨论(0)
  • 2021-01-12 03:04
    InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    
    imm.showSoftInput(view, flags)
    

    an example may be:

    InputMethodManager imm = (InputMethodManager) RouteMapActivity.this
        .getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(mapView, InputMethodManager.SHOW_IMPLICIT);
    
    0 讨论(0)
提交回复
热议问题