Android-----完全隱藏軟鍵盤

來源:互聯網
上載者:User

標籤:des   android   http   io   ar   sp   java   on   div   

隱藏軟鍵盤一直是我頭痛的事情,沒有找到一種真正能隱藏的方法。點擊EditText的時候總是彈出軟鍵盤。-----杯具

 

杯具(一):

Java代碼  
  1. InputMethodManager im =(InputMethodManager) mEdit   
  2. .getContext() .getSystemService(Context.INPUT_METHOD_SERVICE);  
  3.   
  4. im.hideSoftInputFromWindow(SoftKeyTest.this.getCurrentFocus().getWindowToken(),   
  5.             InputMethodManager.HIDE_NOT_ALWAYS);  

 杯具(二):

 

Xml代碼  
  1. <activity android:name=".SoftKeyTest"  
  2.                   android:windowSoftInputMode="stateAlwaysHidden"//加入這行  
  3.                   android:label="@string/app_name">  
  4.             <intent-filter>  
  5.                 <action android:name="android.intent.action.MAIN" />  
  6.                 <category android:name="android.intent.category.LAUNCHER" />  
  7.             </intent-filter>  
  8.         </activity>  

 杯具(三):

Java代碼  
  1. mEdit.setOnClickListener(new View.OnClickListener() {  
  2.               
  3.    @Override  
  4.   public void onClick(View v) {  
  5.   // TODO Auto-generated method stub  
  6.     求求你別出來了;              
  7.   }  
  8. });  

 

一個一個嘗試,這個參數終於把軟鍵盤隱藏了:

 洗具(一):

Java代碼  
  1. EditText et=(EditText)findViewById(R.id.edit);  
  2.   
  3. et.setInputType(InputType.TYPE_NULL);  

Android-----完全隱藏軟鍵盤

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.