Android調用系統軟鍵盤


/**

 * 

 * @MethodName:closeInputMethod

 * @Description:關閉系統軟鍵盤

 * @throws

 */

public void closeInputMethod(){

try {

((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE))

.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),

InputMethodManager.HIDE_NOT_ALWAYS);

catch (Exception e) { }finally{ }

}

/**

 * 

 * @MethodName:openInputMethod

 * @Description:打開系統軟鍵盤

 * @throws

 */

public void openInputMethod(final EditText editText){

Timer timer = new Timer();

timer.schedule(new TimerTask() {

public void run() {

InputMethodManager inputManager = (InputMethodManager) editText

.getContext().getSystemService(

Context.INPUT_METHOD_SERVICE);

inputManager.showSoftInput(editText, 0);

}

}, 200);

}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM