导航视图android没有在R.id.home上触发onOptionsItemSelected

时间:2016-08-09 14:25:48

标签: android android-navigation-drawer android-navigationview

我已经从android studio创建了导航抽屉活动,并且在onOptionsItemSelected方法中我试图抓住汉堡包图标的点击但它不起作用。 我唯一改变的是:

@Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == android.R.id.home) {
            Log.w("ACTIVITY","home pressed");
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

0 个答案:

没有答案