简体   繁体   中英

How can i set different onBackPressed() for different fragment of a NavigationDrawer Activity?

II need to change the toolbar icon of my main_activity(Navigation Drawer Activity) and replace it with back icon and with a different function(go back).

How can i change different toolbar with different function for all my fragment?

I'd suggest starting a new activity instead. This way you don't have to modify the drawer icon and touch handling of the icon is also separated. (You would just close your new activity when the up navigation is clicked).

However, if you want to do it all in your current Activity, you need to change the ActionBar / Toolbar icon and override the clickListener of the navigation icon.

toolbar.setNavigationIcon(R.drawable.ic_arrow_back);

and

toolbar.setNavigationOnClickListener(yourClickListener);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM