zoukankan      html  css  js  c++  java
  • 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毫秒后才开始弹出软键盘。经测试,效果明显。  

  • 相关阅读:
    django的模板层
    django的视图层
    django的路由层
    web应用与http协议
    索引
    pymysql模块的使用
    多表查询
    单表查询
    数据的增删改
    自定义form组件
  • 原文地址:https://www.cnblogs.com/ganchuanpu/p/7011559.html
Copyright © 2011-2022 走看看