android安卓editText自动弹出软键盘(输入键盘)


editext获取焦点并自动弹出输入键盘,代码如下:

    EditText  editText.setFocusable(true);    
    editText.setFocusableInTouchMode(true);    
    editText.requestFocus();    
    InputMethodManager inputManager =(InputMethodManager)editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);    
    inputManager.showSoftInput(editText, 0);

如果是已经入某个界面就要立刻弹出输入键盘,可能会由于界面未加载完成而无法弹出,需要适当延迟,比如延迟500毫秒:

Timer timer = new Timer();    
     timer.schedule(new TimerTask()    
     {    
         public void run()     
         {    
             InputMethodManager inputManager =(InputMethodManager)editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);    
             inputManager.showSoftInput(editText, 0);    
         }    
     },500);