zoukankan      html  css  js  c++  java
  • Android收起虚拟键盘

    关于收起虚拟键盘,网上能找到的大多是这个:

    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);  
    		imm.hideSoftInputFromWindow(editText.getWindowToken(), 0) ;

    只是这有个问题。比方我们在一个页面中有非常多editText,到最后提交的时候我们并不知道实际光标停留在哪个editText。

    除非一个一个遍历推断。那么该怎么办呢?我后来找到这个方案:

    InputMethodManager imm =  (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); 
    if(imm != null) { 
    	
    imm.hideSoftInputFromWindow(getWindow().getDecorView().getWindowToken(),  
    		    		   0); 
    		    		 }

    这个便不用提供绑定的editText。完美解决


查看全文
  • 相关阅读:
    Visual Studio 插件的开发
    EntityFramework 4.x 使用中遇到的问题 (2)
    F#学习笔记核心类型(二)
    F#学习笔记函数式编程(一)
    EntityFramework 4.x 使用中遇到的问题 (1)
    vue3项目一些小坑
    记一种拖拉拽编排流程的思路
    隐藏Jenkinsfile敏感信息
    Jenkins条件判断
    Jenkins 流水线语法自动部署
  • 原文地址:https://www.cnblogs.com/ldxsuanfa/p/10496082.html
  • Copyright © 2011-2022 走看看