简体   繁体   中英

Popup Window InputEventReceiver Error - Android

I dont like errors. I'm using a Popup Window to display a little hint above a TextView. the hint is for explanation of what the TextView is saying, for example RBI, will popup a hint saying "Runs batted in" I keep getting this error W/InputEventReceiver﹕ Attempted to finish an input event but the input event receiver has already been disposed. everytime i click outside of the popup hint to remove the popup, which is the way i want it to be setup, i get that error. I've tried setting the input to INPUT_METHOD_NOT_NEEDED and nothing

i have multiple hints to be shown, so i put everything in an TextView array and i have a listener on each TextView item

method to run the popup

public void displayPopupWindow(View anchorView, String text) {
    final PopupWindow popup = new PopupWindow(getApplicationContext());
    View layout = getLayoutInflater().inflate(R.layout.test_popup, null);
    ((TextView) layout.findViewById(R.id.popup_text)).setText(text);
    popup.setContentView(layout);
    // Set content width and height
    popup.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
    popup.setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
    // Closes the popup window when touch outside of it - when looses focus
    popup.setOutsideTouchable(true);
    popup.setTouchable(false);
    popup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
    // Show anchored to button
    popup.setBackgroundDrawable(new BitmapDrawable());
    popup.showAsDropDown(anchorView, 0, -225);
}

i create a listener

View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String text = "";
            ...
            //a bunch of code that just decides what the variable text should be
            ...
            displayPopupWindow(v, text);
        }
    };

and the array of TextViews listeners is set to the listener object

//inside a for loop
TextViews[i].setOnClickListener(listener);

anyone know of anyway to rid of that error. i wouldnt want the logcat to fill up with those errors. anyone have any ideas how to fix this?

your error is a common error if you search on google,

you have to call your displaypopup method with an handler.

You can find more help here or here .

Hope i helps you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM