只需如下设置就可搞定:
EditText edittext = (EditText)findViewById(R.id.edittext);edittext.setFocusable(true);edittext.setFocusableInTouchMode(true);edittext.requestFocus();Timer timer = new Timer();timer.schedule(new TimerTask() {public void run() {InputMethodManager inputManager =(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);inputManager.showSoftInput(edittext, 0);}},200);
值得注意的是,刚进去当整个view还没有构建完毕,执行弹出软键盘是没有效果的,所以这里加了个定时器,当进到页面后200毫秒后才开始弹出软键盘。经测试,效果明显。
如果觉得《Android进入页面开始就自动弹出软键盘》对你有帮助,请点赞、收藏,并留下你的观点哦!