Reputation: 389
I made a transition animation from one activity to another via clickListener. Now I want to add it on the back button of the Toolbar to go back. I already set the parent activities, but I have no idea how to implement animation on the back button.
Upvotes: 1
Views: 787
Reputation: 5741
Override the onBackPressed() method and apply your transition and call finish. To handle toolbar back click event override following method.
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == android.R.id.home) {
onBackPressed();
}
return super.onOptionsItemSelected(menuItem);
}
Upvotes: 3