Android:如何禁用打开导航抽屉的ActionBar按钮

问题描述:

如何禁用打开导航抽屉的ActionBar按钮?

How to disable the ActionBar button that opens navigation drawer?

我使用以下代码禁用通过滑动打开导航抽屉的操作,但是其操作栏按钮(位于顶部/左侧)仍然处于活动状态,可以用来打开导航抽屉.

I use the code below to disable opening the navigation drawer using swipe, but its action bar button (at Top/Left) still active and can be used to open the navigation drawer.

 DrawerLayout navigationDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
 navigationDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);

尝试一下,我认为它将为您提供帮助

Try This i think it Will help you

actionBar.setDisplayHomeAsUpEnabled(false);

或者您可以使用此

getActionBar().setDisplayHomeAsUpEnabled(false);