Спрятать показать клаву программно можно примерно так:
| Код | public static void showSoftKeyboardOnView(@NotNull final View view) { (new Handler()).postDelayed(new Runnable() { public void run() { Log.i(TAG, "Opening keyboard on view " + view);
view.requestFocus();
// Yes, I know what you are thinking about that. If you knew something better by any chance it would be magnificent to have your idea here in code. view.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, 0, 0, 0)); view.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, 0, 0, 0)); } }, 200); }
public static void hideSoftKeyboardOnView(@NotNull View view) { Log.i(TAG, "Closing keyboard on view " + view); InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); }
|
|