簡體   English   中英

彈出窗口InputEventReceiver錯誤-Android

[英]Popup Window InputEventReceiver Error - Android

我不喜歡錯誤。 我正在使用彈出窗口在TextView上方顯示一些提示。 提示是什么TextView的是說,例如打點的解釋,會彈出一個提示說我不斷收到此錯誤“擊球后跑” W/InputEventReceiver﹕ Attempted to finish an input event but the input event receiver has already been disposed. 每次我在彈出窗口提示之外單擊以刪除彈出窗口時(這是我想要設置的方式),就會收到該錯誤。 我嘗試將輸入設置為INPUT_METHOD_NOT_NEEDED ,什么也沒有

我有多個提示要顯示,所以我將所有內容都放在一個TextView數組中,並且每個TextView項都有一個偵聽器

運行彈出窗口的方法

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);
}

我創建一個監聽器

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);
        }
    };

並將TextViews偵聽器的數組設置為偵聽器對象

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

任何人都知道擺脫該錯誤。 我不想讓logcat充滿那些錯誤。 任何人有任何想法如何解決此問題?

如果您在google上搜索,則您的錯誤是常見錯誤,

您必須使用處理程序來調用displaypopup方法。

您可以在此處此處找到更多幫助。

希望我能幫助你

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM