2012年8月31日 星期五

(Android Note) 呼叫鍵盤

1. Code

1.1 呼叫鍵盤功能,如果鍵盤顯示狀態就隱藏、鍵盤隱藏狀態就顯示。

 InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 

imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);

1.2 只隱藏鍵盤

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

imm.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(),InputMethodManager.HIDE_NOT_ALWAYS);

沒有留言:

張貼留言