Open navigation drawer when options menu button is pressed

It is easy to open the navigation drawer from option menu. Place the following code in your main activity class.

[code lang=”java”]
@Override
public boolean onKeyDown(int keyCode, KeyEvent e)
{
if (keyCode == KeyEvent.KEYCODE_MENU)
{
if (!mDrawerLayout.isDrawerOpen(mDrawerLinear))
{
mDrawerLayout.openDrawer(mDrawerLinear);
}
return true;
}
return super.onKeyDown(keyCode, e);
} 0

About the author

Janaki(http://mjanaki.com) - A Software developer with 9+ years of experience in multiple technology projects across web, mobile, and cloud applications with expertise in PHP, C#, MySQL, Web services and open source platforms.

Similar Posts

Comments are closed.