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); } 
  • Add a picture not a link, but a picture. And the thing is, apparently, in styles. Show them - Yuriy SPb
  • Changed the style to: <style name = "AppTheme" parent = "Theme.AppCompat"> and worked. But now the default colors have changed. For example, the text used to be black, now it will be white, the background was white, now black. But this can already be changed in XML - FLWRZ4U
  • one
    Try Theme.AppCompat.Light and / or colorPrimary in styles change. - Yuriy SPb

2 answers 2

The click is processed in the onOptionsItemSelected(Menu menu) , which can be redefined and by taking the id of the item that the user clicked on can be easily processed.

If that id of the button is back, if not a custom one, which can be noticed by your code, then it will be android.R.id.home , if not exactly indicated, please correct.

    That's right, handled in onOptionsItemSelected , like this:

     @Override public boolean onMenuItemSelected(int featureId, MenuItem item) { int itemId = item.getItemId(); switch (itemId) { case android.R.id.home: Toast.makeText(this, "home pressed", Toast.LENGTH_LONG).show(); break; } return true; }