zoukankan      html  css  js  c++  java
  • EditText中关闭或者隐藏输入法

    1、EditText有焦点(focusable为true)阻止输入法弹出 

    Java代码 
    1. editText=(EditText)findViewById(R.id.txtBody);  
    2.   
    3.         editText.setOnTouchListener(new OnTouchListener() {               
    4.   
    5.             public boolean onTouch(View v, MotionEvent event) {    
    6.   
    7.                 editText.setInputType(InputType.TYPE_NULL); // 关闭软键盘        
    8.   
    9.                 return false;  
    10.   
    11.             }  
    12.   
    13.         });    



    2、当EidtText无焦点(focusable=false)时阻止输入法弹出  

    Java代码 
    1. InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);       
    2.   
    3.        imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);      



    3、显示输入法 

    Java代码 
    1. InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);       
    2. imm.showSoftInput(m_receiverView(接受软键盘输入的视图(View)),InputMethodManager.SHOW_FORCED(提供当前操作的标记,SHOW_FORCED表示强制显示));    



    4、隐藏输入法 

    Java代码 
    1. ((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(WidgetSearchActivity.this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);  (WidgetSearchActivity是当前的Activity)    



    5、获取输入法状态 

    Java代码 
      1. InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);  
      2. boolean isOpen=imm.isActive();  
      3. isOpen若返回true,则表示输入法打开  
  • 相关阅读:
    Lighthead SiteCrawler
    svnbook
    SFTP in Python: Really Simple SSH
    WP Robot Wordpress plugin logo
    use curl to post data for work punch
    Setting up Hudson on port 80 on a Debian or Ubuntu machine
    Problem with PEXPECT in Python
    H2 Database Engine — h2database.com — Readability
    execnet: rapid multiPython deployment
    Maven问题总结 3 技术改变生活商业成就梦想 51CTO技术博客
  • 原文地址:https://www.cnblogs.com/garygou/p/3067053.html
Copyright © 2011-2022 走看看