zoukankan      html  css  js  c++  java
  • 动态显示/隐藏软键盘

    4.动态显示软键盘

     

    @TargetApi(Build.VERSION_CODES.CUPCAKE)

    public static void showSoftInput(Context context, EditText edit) {

            edit.setFocusable(true);

            edit.setFocusableInTouchMode(true);

            edit.requestFocus();

            InputMethodManager inputManager = (InputMethodManager) context

                    .getSystemService(Context.INPUT_METHOD_SERVICE);

            inputManager.showSoftInput(edit, 0);

        }

     

    5.动态显示或者是隐藏软键盘

     

    @TargetApi(Build.VERSION_CODES.CUPCAKE)

    public static void toggleSoftInput(Context context, EditText edit) {

            edit.setFocusable(true);

            edit.setFocusableInTouchMode(true);

            edit.requestFocus();

            InputMethodManager inputManager = (InputMethodManager) context

                    .getSystemService(Context.INPUT_METHOD_SERVICE);

            inputManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);

        }

    -----------------------------------------------------------------------------------------------

    动态隐藏软键盘

    InputMethodManager imm = (InputMethodManager)
                getSystemService(Context.INPUT_METHOD_SERVICE);
                 if(imm != null) {  
                     imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
                 }

  • 相关阅读:
    检测浏览器是否支持DOM2级规定的HTML事件
    click冒泡到body
    浏览器事件归类
    兼容主流浏览器的事件处理程序
    eventPhase三个状态测试
    鼠标滚轮事件(mousewheel)
    自定义右键菜单(contextmenu)
    数据库范式
    敏捷开发模式
    没有清晰的职业规划,跳槽会很失败
  • 原文地址:https://www.cnblogs.com/Jingerxin/p/5327704.html
Copyright © 2011-2022 走看看