I'm trying to make a popup window appear from an IME service (an onscreen
keyboard) that has no activity. When I call popUp.showAtLocation(layout,
Gravity.CENTER, 0, -100) I get a "Windowmanager$BadTokenException: Unable
to add window -- token null is not valid."
Here is my code:
public void initiatePopupWindow()
>
> {
>
> try {
>
> LayoutInflater inflater = (LayoutInflater) this
> .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
>
> View layout = inflater.inflate(R.layout.popup_layout,null);
>
>
>
> // create a 300px width and 470px height PopupWindow
>
> popUp = new PopupWindow(layout, 300, 470, true);
>
> popUp.showAtLocation(layout, Gravity.CENTER, 0, -100);
>
>
>
>
>
> Button cancelButton = (Button) layout.findViewById(R.id.
> popup_cancel_button);
>
> cancelButton.setOnClickListener(inputView.
> cancel_button_click_listener);
>
>
>
> } catch (Exception e) {
>
> e.printStackTrace();
>
> }
>
> }
>
Any help would be appreciated. Thank you
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en