Neoh
Neoh

Reputation: 16164

Navigation drawer will close even if overwrite onBackPressed()

Is there a way to prevent navigation drawer from closing when back button is pressed? For testing purpose I make the call to onBackPressed() empty

@Override
public void onBackPressed() {

}

but the navigation drawer still responds to the back button and close. Other cases the back button is non-responsive as I expected. What should I overwrite in order to prevent navigation drawer from closing?

Upvotes: 7

Views: 2259

Answers (1)

Dennis
Dennis

Reputation: 486

Call in onCreate() in your activity

mDrawerLayout.setFocusableInTouchMode(false);

and handle the closing/opening logic yourself in OnBackPressed().

Upvotes: 12

Related Questions