Friday, 31 July 2015

android actionbar -- have a back button


People said "android:parentActivityName will give you a back button on your action bar":


However that is not true:

This line of the code will give you the back button:

getSupportActionBar().setDisplayOptions(getSupportActionBar().getDisplayOptions() | ActionBar.DISPLAY_HOME_AS_UP);

According to:

http://developer.android.com/intl/ko/reference/android/app/ActionBar.html

intDISPLAY_HOME_AS_UPDisplay the 'home' element such that it appears as an 'up' affordance.

This will give your the back button , but doesn't give you the functionality of show you the previous page. The redirecting should be done in another place.

In AndroidManifest.xml, by puting this in an activity:

<meta-data    android:name="android.support.PARENT_ACTIVITY"
android:value="cxxxxx" />


It is doesn't matter the value, but you must have it.







No comments:

Post a comment