Add hideKeyboard util method.

This commit is contained in:
dddddd-mmmmmm 2020-01-13 23:36:35 +11:00
parent bf9e9ad1e6
commit 02d94e1a6c
1 changed files with 9 additions and 0 deletions

View File

@ -41,9 +41,12 @@ import android.text.util.Linkify;
import android.util.Log; import android.util.Log;
import android.util.SparseArray; import android.util.SparseArray;
import android.view.Gravity; import android.view.Gravity;
import android.view.inputmethod.InputMethodManager;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import android.app.Activity;
import android.view.View;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.StringRes; import androidx.annotation.StringRes;
@ -1135,4 +1138,10 @@ public final class Util {
return random; return random;
} }
public static void hideKeyboard(View view) {
InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
} }