Attempted to finish an input event but input event receiver has already been disposed

天大地大妈咪最大 提交于 2019-11-28 22:54:07

I've hit this problem from another angle; trying to launch a service from a menu. By default, the debug message is not too relevant. My solution was to eliminate filters in logcat and then I got another message that it could not launch the service in the first place (I forgot to put it in my manifest file).

In your case, you may need to wrap the toast display into a class:

public class DisplayToast implements Runnable {
    private final Context mContext;
    private final String mText;

    public DisplayToast(Context mContext, String text) {
        this.mContext = mContext;
        mText = text;
    }

    public void run() {
        Toast.makeText(mContext, mText, Toast.LENGTH_SHORT).show();
    }
}

and call it via a Handler object:

mHandler.post(new DisplayToast(this, "Epic message!"));

Or, even better, using Handler.postDelayed() method.

HTH,

You have to pass the R.layout.id in the super() to prevent this error. For example:

public PersonAdapter(Context c, ArrayList<String> list) {
            super(c, R.layout.item_layout, list);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!