I'm trying to emulate a software keyboard for a domain specific input. I'm using a PopupWindow to gather the input and transfer it to the underlying EditText. Unfortunately, the PopupWindow is modal, so the user cannot switch from one EditText to another as they can with the usual software keyboard. I've looked into setting the FLAG_NOT_TOUCH_MODAL
flag, but I'm not sure when or to what it should be applied to get the behavior I'm looking for.
My code for launching the PopupWindow looks like:
myEdit.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
pw = myKeyboard.getPopupWindow((EditText) v);
pw.showAtLocation(Main.this.findViewById(R.id.main), Gravity.BOTTOM, 0, 0);
}
});
I tried changing it to the following, but this only resulted in the runtime exception: java.lang.RuntimeException: view android.widget.LinearLayout@40526268 being added, but it already has a parent
myEdit.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
pw = myKeyboard.getPopupWindow((EditText) v);
WindowManager.LayoutParams wlp = getWindow().getAttributes();
wlp.gravity = Gravity.BOTTOM;
wlp.flags = wlp.flags | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
getWindow().addContentView(pw.getContentView(), wlp);
pw.showAtLocation(Main.this.findViewById(R.id.main), Gravity.BOTTOM, 0, 0);
}
});
I'm also looking into setOutsideTouchable, but so far I haven't gotten anywhere.
Any pointers on how I can create a modeless PopupWindow? I would be willing to use some other modeless widget.