我的活动上有一个PopupWindow,popupWindow具有“编辑”文本。问题是,当我将外部可触摸的弹出窗口设置为false时,编辑文本无法在android的弹出窗口中打开键盘,并且我通过在弹出窗口内设置取消按钮来关闭弹出窗口。请事先感谢您的帮助。
LayoutInflater inflater = (LayoutInflater)
getSystemService(LAYOUT_INFLATER_SERVICE);
final View popupView = inflater.inflate(R.layout.repeat, null);
int width = LinearLayout.LayoutParams.MATCH_PARENT;
int height = LinearLayout.LayoutParams.WRAP_CONTENT;
boolean focusable = false;
final PopupWindow popupWindow = new PopupWindow(popupView, width, height, focusable);
// show the popup window
// which view you pass in doesn't matter, it is only used for the window tolken
popupWindow.showAtLocation(view, Gravity.CENTER, 0, 0);
final LinearLayout until = popupView.findViewById(R.id.Until);
Button pop_done = popupView.findViewById(R.id.pop_done);
Button pop_cancel = popupView.findViewById(R.id.pop_cancel);
dropdown = popupView.findViewById(R.id.spinner);
final EditText repetition = popupView.findViewById(R.id.repeat_times);
[repetition.requestFocus();
应该显示键盘。
尝试一下
LayoutInflater inflater = (LayoutInflater)
getSystemService(LAYOUT_INFLATER_SERVICE);
final View popupView = inflater.inflate(R.layout.repeat, null);
int width = LinearLayout.LayoutParams.MATCH_PARENT;
int height = LinearLayout.LayoutParams.WRAP_CONTENT;
final PopupWindow popupWindow = new PopupWindow(popupView, width, height);
popupWindow.setFocusable(true);
popupWindow.update();
// show the popup window
// which view you pass in doesn't matter, it is only used for the window tolken
popupWindow.showAtLocation(v, Gravity.CENTER, 0, 0);
popupWindow.setOutsideTouchable(false);
final LinearLayout until = popupView.findViewById(R.id.Until);
Button pop_done = popupView.findViewById(R.id.pop_done);
Button pop_cancel = popupView.findViewById(R.id.pop_cancel);
Spinner dropdown = popupView.findViewById(R.id.spinner);
final EditText repetition = popupView.findViewById(R.id.repeat_times);