InputEventReceiver:尝试完成输入事件,但输入事件接收器已被释放

时间:2016-01-14 07:29:12

标签: android contextmenu

我试图在我的应用中创建浮动上下文菜单,但onContextItemSelected未启动,当我触摸任何菜单选项时,它会给我错误InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed.
我的代码如下所示:

public class onDeleteClickClass implements Runnable {
        private int position;

        public onDeleteClickClass(int position) {
            this.position = position;
        }

        public void run() {
            onDeleteClick(position);
        }
    }
    public void onDeleteClick(int position) {
        if (KeyID.contains(listAdapter2.reviewHasPhotos[position])) {
            reviewPids = listAdapter2.reviewPid[position];
            new DeleteReview().execute();
            listView = (ListView) findViewById(R.id.restaurantReviews);
            listView.setAdapter(null);
            new ReadAllReviews().execute();
        }
    }

    public void onEditClick(int position) {
        if (KeyID.contains(listAdapter2.reviewHasPhotos[position])) {
            Intent intent = new Intent(getApplicationContext(), makeReviewActivity.class);
            intent.putExtra("edit", true);
            startActivity(intent);
            finish();
        }
    }

    @Override
    public boolean onContextItemSelected(MenuItem item) {
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo)
                item.getMenuInfo();
        switch (item.getItemId()) {
            case R.id.id_edit:
                onEditClick(info.position);
                return true;
            case R.id.id_delete:
                mHandler.post(new onDeleteClickClass(info.position));
                return true;
            case R.id.id_share:
                return true;
            default:
                return super.onContextItemSelected(item);
        }
    }

正如你所看到的,我从其他问题中尝试了一些事情,但那不起作用。

0 个答案:

没有答案