Skip to content

PopupWindow中EditText无法编辑,无法弹出软键盘

要解决这个问题,需要对PopupWindow进行设置。设置popupWindow允许获得关注。 新建对象时设置focusable=true,或popupWindow.setFocusable(true)

popupWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
popupWindow.setOutsideTouchable(true);
popupWindow.setFocusable(true);

popupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

作者: RustFisher
联系: rf.cs@foxmail.com
博客: rustfisher.com | RustFisher cnblog
示例: AndroidTutorial Gitee, Tutorial Github
链接: https://www.an.rustfisher.com/android/ui/widget/popupwindow/edit-text-cannot-eidt/
一家之言,仅当抛砖引玉。如有错漏,还请指出。