首页 > 移动平台 > 详细

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

时间:2016-11-10 22:06:28      阅读:700      评论:0      收藏:0      [点我收藏+]


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);


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

原文:http://11020803.blog.51cto.com/11010803/1871455

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!