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

  • 相关阅读:
    4-17 文字图片绘制
    4-16 矩形圆形任意多边形绘制
    4-15 线段绘制
    4-14 图像特效小结
    4-13 油画特效
    4-12 颜色映射
    4-11 浮雕效果
    Linux文本截取命令cut​笔记
    45张令程序员泪流满面的趣图
    45张令程序员泪流满面的趣图
  • 原文地址:https://www.cnblogs.com/Jingerxin/p/5327704.html
Copyright © 2011-2022 走看看