When starting a new Activity with an Intent, does the bar on the top of an Activity provide a back button automatically? I assumed that's how it works but am not seeing it. If it doesn't appear automatically, what's required to make it appear?
Asked
Active
Viewed 514 times
0
-
2Have you even tried searching? There are already a lot of answers about this, for instance: http://stackoverflow.com/questions/14545139/android-back-button-in-the-title-bar – Squeazer Nov 08 '14 at 21:11
-
@Squeazer Thanks for pointing me to that! I did try searching but strangely nothing useful came up. That answered my question completely. – user2345093 Nov 08 '14 at 21:36
2 Answers
0
hey if i am right you looking for home up button in action bar
see like that, put this in your new activity
getActionBar().setTitle("");
getActionBar()
.setBackgroundDrawable(
new ColorDrawable(getResources().getColor(
R.color.actionBarBg)));
getActionBar().setDisplayHomeAsUpEnabled(true);
put before setContentView
and it handled by menus
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
default:
break;
}
return false;
}
thanks

Saveen
- 4,120
- 14
- 38
- 41
0
First, the intent which you insert in a startActivity() method, which starts the activity that you want is not related at all with the back arrow on the toolbar() of the activity.
Second, you should see this : Android - Back button in the title bar. Maybe, this will work out.
Don't forget to add the meta-data in the manifest! You don't want a "hidden" "NullPointerException".

Community
- 1
- 1

Rares-Mihai Chelariu
- 79
- 1
- 7