0
我按照下面的代碼打開: -鍵盤保持在工具欄返回箭頭按下
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// handle arrow click here
if (item.getItemId() == android.R.id.home) {
finish();
overridePendingTransition(R.transition.right_in, R.transition.right_out);
}
return super.onOptionsItemSelected(item);
}
在這個時候,我的鍵盤是開放的,我按我的工具欄回來arrrow,鍵盤保持開放和活動得到完成。我試圖強行callling以下方法上暫停()隱藏鍵盤,但並不好看,而轉變: -
public static void hideKeyboard(Activity activity) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
//Find the currently focused view, so we can grab the correct window token from it.
View view = activity.getCurrentFocus();
//If no view currently has focus, create a new one, just so we can grab a window token from it
if (view == null) {
view = new View(activity);
}
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
@ Adley-經過我和整理活動之前試過這個隱藏鍵盤,問題是當它返回到前一個畫面..它顯示鍵盤的一些空白區域,同時隱藏它,這看起來真的很難看,因爲用戶體驗。 –
你測試過其他設備,物理設備嗎?這是奇怪的... – Adley
是的,我已經嘗試與三星s6和摩托g2 ..但結果是相同的,這很奇怪。 –