getMenuInflater().inflate unreachable statement

https://stackoverflow.com/questions/46666987/getmenuinflater-inflater-menu-my-menu-menu-error-unreachable-statement


写菜单的时候照代码打的

getMenuInflater().inflate(R.menu.main,menu);报错unreachable
看了上面网站是重写方法时附带的return super.onCreateOptionsMenu(menu);没有注意到直接在下面写代码了。。。
然后应该是这样:不想点开网站看这儿
@Override
        public boolean onCreateOptionsMenu(Menu menu) {
            MenuInflater inflater = getMenuInflater();
            inflater.inflate(R.menu.main, menu);
            return super.onCreateOptionsMenu(menu);
        }

你可能感兴趣的:(Mune)