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

  • 相关阅读:
    约瑟夫
    用过的ps操作
    guns框架试用笔记
    让使用WebForm的.aspx文件写的WebApi能够跨域访问
    DevExpress的GridView的行变和列变
    SSMS18.0缺少调试功能
    EF_CodeFirst框架版本问题
    微信小程序框架了解2---js的写法
    微信小程序框架了解1---总体了解
    Chrome浏览器写代码片段的地方
  • 原文地址:https://www.cnblogs.com/Jingerxin/p/5327704.html
Copyright © 2011-2022 走看看