1.弹出软键盘Timer timer = new Timer(); timer.schedule(new TimerTask() { //让软键盘延时弹出,以更好的加载Activity public void run() { InputMethodManager inputManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);inputManager.showSoftInput(et_yourEditText, 0); }}, 300);if (inputManager != null)2.隐藏软键盘Timer timer = new Timer(); timer.schedule(new TimerTask() { public void run() { try { InputMethodManager inputManager = (InputMethodManager) activity. getSystemService(Context.INPUT_METHOD_SERVICE); if (inputManager != null) inputManager.hideSoftInputFromWindow(activity.getWindow().getDecorView().getWindowToken(), 0); } catch (ClassCastException e) { VLog.d("Context is not Activity"); } } }, 300);3.切换软键盘状态Timer timer = new Timer(); timer.schedule(new TimerTask() { //让软键盘延时弹出,以更好的加载Activity public void run() { InputMethodManager inputManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); } }, 300);
安卓软件盘的开启与关闭
最新推荐文章于 2021-05-26 17:27:52 发布