java android-hide-keyboard.java

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java android-hide-keyboard.java相关的知识,希望对你有一定的参考价值。

// Only works in Activity
private void hideKeyboard() {
    InputMethodManager inputMethodManager
            = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
    // Find the currently focused view, so we can grab
    // the correct window token from it.
    View view = getCurrentFocus();
    // If no view currently has focus, create a new one,
    // just so we can grab a window token from it
    if (view == null) {
        view = new View(this);
    }
    inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

以上是关于java android-hide-keyboard.java的主要内容,如果未能解决你的问题,请参考以下文章

Java 布尔运算

java [Java] Java常用代码#java

Java - 35 Java 实例

Java While 循环

Java 字符串

Java If ... Else