欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android之軟鍵盤自動彈出和關(guān)閉【代碼分享】

 更新時間:2017年04月13日 09:20:37   作者:瞳瞳色丶輕煙的博客  
本文主要介紹了Android中軟鍵盤自動彈出和關(guān)閉的相關(guān)知識。具有很好的參考價值。下面跟著小編一起來看下吧

一:軟鍵盤自動彈出。

private EditText top_middle;//輸入框

//-------------------------------------彈出軟鍵盤-----------------------------------
top_middle.setFocusable(true);
top_middle.setFocusableInTouchMode(true);
top_middle.requestFocus();
InputMethodManager inputManager =
(InputMethodManager) top_middle.getContext().getSystemService(
   Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(top_middle, 0);
Timer timer = new Timer();
timer.schedule(new TimerTask()
{
  public void run()
  {
   InputMethodManager inputManager =
   (InputMethodManager) top_middle.getContext().getSystemService(
      Context.INPUT_METHOD_SERVICE);
   inputManager.showSoftInput(top_middle, 0);
  }
},

998);

二:軟鍵盤自動關(guān)閉。

//-----------------------------------軟鍵盤自動關(guān)閉----------------------------------------
InputMethodManager imm = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(top_middle.getWindowToken(), 0);

三:對話框中軟鍵盤自動彈出和關(guān)閉。

//--------------------------------對話框中自動彈出和關(guān)閉-----------------------------------
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

以上就是本文的全部內(nèi)容,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,同時也希望多多支持腳本之家!

相關(guān)文章

最新評論