Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had a similar problem with the soft keyboard; though in my case it would not show even without switching views with setContentView. After some experimenting I've found the solution which still works for me. The idea was to intercept soft keyboard showing/hiding for any EditText descendant. For this I overrode onWindowFocusChanged of the Activity.</p> <p>The trick was in hiding the keyboard when it is not needed anymore. </p> <p>As you can see I used toggleSoftInput with SHOW_IMPLICIT instead of any HIDE constant. In this case IMEManager would retain the keyboard visible only if the focused view requires it otherwise it will be hidden. </p> <pre><code>private boolean softInputActive; @Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); InputMethodManager IMEManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); View focusedView = getCurrentFocus(); // Find the primitive focused view (not ViewGroup) while (focusedView instanceof ViewGroup) { focusedView = ((ViewGroup) focusedView).getFocusedChild(); } if (hasFocus) { if (focusedView instanceof EditText &amp;&amp; focusedView.isEnabled() &amp;&amp; !IMEManager.isActive(focusedView)) { IMEManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); softInputActive = true; } } else if (softInputActive) { if (focusedView != null &amp;&amp; IMEManager.isActive()) { IMEManager.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0); } softInputActive = false; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload