How to add back arrow in action bar android

How to add back arrow in action bar android

Back arrow is used for going to the previous inactivity or fragment. set back arrow action bar android

by using a single line of code we can show this, not even a single line but some words.

If you get a null pointer exception it could depend on the theme. Try using a different theme in the manifest or use this alternatively:

———————————————————–

getSupportActionBar().setDisplayHomeAsUpEnabled(true);

———————————————————–

this will show the arrow on action bar.Add arrow

 

Now on clicking we have to back, so write this code.

you can use the tool bar setNavigationIcon method. Android Doc

———————————————————–
@Override
public boolean onSupportNavigateUp(){
finish();
return true;
}

———————————————————–




Categories: Android

Tags: ,,,

Leave A Reply

Your email address will not be published.

error: Alltutorial.in content is protected !!