Android进入页面开始就自动弹出软键盘

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毫秒后才开始弹出软键盘。经测试,效果明显。  

原文地址:https://www.cnblogs.com/ganchuanpu/p/7011559.html