// 获取编辑框焦点 editText.setFocusable(true);
activity_friend_ring_bottom.setFocusable(true); activity_friend_ring_bottom.setFocusableInTouchMode(true); activity_friend_ring_bottom.requestFocus(); //打开软键盘 InputMethodManager imm = (InputMethodManager) ctx .getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); //关闭软键盘 imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
/** 定义PopupWindow **/ private void initPopuWindow() { View view = getLayoutInflater().inflate(R.layout.adapter_friend_ring_replay_dialog, null); selectPopupWindow = new PopupWindow(view, android.view.ViewGroup.LayoutParams.FILL_PARENT,android.view.ViewGroup.LayoutParams.WRAP_CONTENT, false); selectPopupWindow.setFocusable(true); selectPopupWindow.setBackgroundDrawable(new BitmapDrawable()); selectPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); selectPopupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0); InputMethodManager im = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); im.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); }
// 注意必须在AndroidManifest.xmlAndroidManifest.xml文件中添加android:windowSoftInputMode="adjustPan" 防止键盘关闭的时候是黑色