I need to make a return button, like with a collapseActionView in the menu. Do you need to do it yourself for example through imageView or are there any built-in methods, for example from the backward support library?

  • What is the return button ? - Vladyslav Matviienko
  • The collapseActionView attribute is used to collapse / expand a widget like SearchView , what return and where is your question? - pavlofff

1 answer 1

We show the button using getActionBar().setDisplayHomeAsUpEnabled(true) , or if you use the Lieb saver, then getSupportActionBar().setDisplayHomeAsUpEnabled(true); . Further to catch clicking on it we add the code:

 @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: // тут пишем код обработки нажатия return true; } return super.onOptionsItemSelected(item); }