在Fragment下控制實體返回鍵 在EditTextOverWrite(客制的EditText) 狀態下,會有鍵盤彈出,在這個時候硬體控制權會被系統搶走,因此要加判斷 若該頁面沒有EditText,則無須理會IsKeyboardHidden以及其function Java部分 private EditTextOverWrite editEmailLoginAccount,editEmailLoginPassword; editEmailLoginAccount = (EditTextOverWrite) view.findViewById(R.id.editEmailLoginAccount); editEmailLoginPassword = (EditTextOverWrite) view.findViewById(R.id.editEmailLoginPassword); editEmailLoginAccount.setOnKeyboardHidden(onKeyboardHidden); editEmailLoginPassword.setOnKeyboardHidden(onKeyboardHidden); view.setFocusableInTouchMode(true); view.requestFocus(); view.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && KeyEvent.ACTION_UP == event.getAction()) { if (IsKeyboardHidden) { IsKeyboardHidden = false; }else { i...
留言
張貼留言