I'm trying to display a Back button
on the Action bar
to move previous page/activity or to the main page (first opening).
And I can not do it.
my code.
ActionBar actionBar = getActionBar();
actionBar.setHomeButtonEnabled(true);
the code is in onCreate
.
Add these lines to onCreate()
and in onOptionItemSelected
Hope this will help you..!
The magic happens in
onOptionsItemSelected
.Try this code, considers it only if you need the back button.
in onCreate method write-
and this is the xml file-
and in styles.xml change it to
this is all what we have to do.
my working code to go back screen.
Manifest.xml