Toolbar Back Button Is Not Calling Onoptionsitemselected Android
I can able to see the back button in the toolbar but when i click, nothing happens. It is not going to onOptionsItemSelected but when i remove the whole implementation of ActionBar
Solution 1:
If you want the onOptionsItemSelected()
method to fire when the toggle Button is clicked, you need to use the four-parameter constructor for ActionBarDrawerToggle
that doesn't take a Toolbar
argument.
publicActionBarDrawerToggle(Activity activity,
DrawerLayout drawerLayout,
int openDrawerContentDescRes,
int closeDrawerContentDescRes)
Otherwise, the toggle will just handle the drawer opening/closing directly itself.
Solution 2:
And i finally got a solution. instead getting toolbar home button click ononOptionsItemSelected()
it can be handled through DrawerToggle.setToolbarNavigationClickListener
.
mDrawerToggle.setToolbarNavigationClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(View v) {
// event when click home buttonLog.d("cek", "home selected");
}
});
Thanks to @meow meo. Source - Cannot catch toolbar home button click event
Post a Comment for "Toolbar Back Button Is Not Calling Onoptionsitemselected Android"