(ActionMenu)W / InputEventReceiver:尝试完成输入事件但输入事件接收器已被处理

时间:2018-03-08 08:35:35

标签: java android menu android-actionbar popupmenu

我制作了动作栏菜单应用程序。但如果单击menuitem,则不会显示Toast Message。 我运行模拟器和手机。但它不起作用。 当我点击menuitem时,logcat显示错误信息:

W/InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed.

这是我的代码:

MainActivity.java

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.mymenu, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.info:
            Toast.makeText(this,"짠",Toast.LENGTH_SHORT);
            return true;
        case R.id.support:
            return true;
        default:
            return  super.onOptionsItemSelected(item);
    }
  }
}

RES /菜单/ mymenu.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
    android:id="@+id/help"
    android:title="help"/>
<item
    android:id="@+id/support"
    android:title="support"/>
</menu>

1 个答案:

答案 0 :(得分:0)

Toast.makeText(this,"짠",Toast.LENGTH_SHORT); Toast.makeText(this,"짠",Toast.LENGTH_SHORT).show();show()调用 return Response.ok(file, MediaType.APPLICATION_OCTET_STREAM*) .header("Content-Disposition", "attachment;filename=somename.xlsx" ) .build(); 方法。希望帮助您。