zoukankan      html  css  js  c++  java
  • Android调用系统软键盘

    /**

     * 

     * @MethodName:closeInputMethod

     * @Description:关闭系统软键盘

     * @throws

     */

    public void closeInputMethod(){

    try {

    ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE))

    .hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),

    InputMethodManager.HIDE_NOT_ALWAYS);

    catch (Exception e) { }finally{ }

    }

    /**

     * 

     * @MethodName:openInputMethod

     * @Description:打开系统软键盘

     * @throws

     */

    public void openInputMethod(final EditText editText){

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

    }

    }, 200);

    }

  • 相关阅读:
    MyBatis总结(一)
    MyBatis简介
    数据持久化与ORM
    主流框架介绍
    JSP数据交互(一)
    tomcat端口被占用
    动态网页开发基础
    jQuery内容
    正则表达式
    初始Mybatis
  • 原文地址:https://www.cnblogs.com/android100/p/android-soft-keyboard.html
Copyright © 2011-2022 走看看