This question has already been answered:

Put the toolbar and made the "Back" button. I do not know how to put a handler on it.

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); } 

Reported as a duplicate by Vladyslav Matviienko , cheops , user194374, aleksandr barakin , Streletz Jun 29 '16 at 12:42 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • @ user2070212 You already asked such a question 3 hours ago. - Lucky_girl
  • @Lucky_girl there was another question, then it was edited. It is necessary to restore order, yes. - Yura Ivanov
  • Ask a question again, they will answer you as soon as you create 99 identical questions. - Vladyslav Matviienko

1 answer 1

Add:

 @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: //Кнопку home нажали return true; default: return super.onOptionsItemSelected(item); } }