閱讀162 返回首頁    go 阿裏雲 go 技術社區[雲棲]


android隱藏與現實鍵盤

 

1. Control by code:

 

     show input method panel:

  1. final View v = getWindow().peekDecorView();  
  2. if (v != null && v.getWindowToken() != null) {  
  3.     InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);  
  4.     imm.toggleSoftInputFromWindow(v.getWindowToken(), 00);  
  5. }  
final View v = getWindow().peekDecorView(); if (v != null && v.getWindowToken() != null) { InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); imm.toggleSoftInputFromWindow(v.getWindowToken(), 0, 0); }

 

     hide input method panel:

 

  1. final View v = getWindow().peekDecorView();  
  2. if (v != null && v.getWindowToken() != null) {  
  3.     InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);  
  4.     imm.hideSoftInputFromWindow(v.getWindowToken(), 0);  
  5. }  
final View v = getWindow().peekDecorView(); if (v != null && v.getWindowToken() != null) { InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); }      

 

 

 

2. Control by manifest parament:

  1. android:windowSoftInputMode=["stateUnspecified",  
  2.                                        "stateUnchanged""stateHidden",  
  3.                                        "stateAlwaysHidden""stateVisible",  
  4.                                        "stateAlwaysVisible""adjustUnspecified",  
  5.                                        "adjustResize""adjustPan"]  

最後更新:2017-04-02 06:51:48

  上一篇:go Asp.Net實現評論蓋樓(含Ajax實現方式)
  下一篇:go [usaco]羅馬數字