Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: wrong transition when using navigateUpFromSameTask()

I'm just starting out with Android and I followed this guide on adding the Up navigation to an Activity on the Action Bar.

http://developer.android.com/training/implementing-navigation/ancestral.html

However, the transition of when I use the up button from the Action Bar makes it show as the fade-in transition of opening a new activity rather than the fade-out that it should be, as it does when pressing the back button on the bottom.

What can I do to make it display the correct transition? Thanks.

like image 627
Linkandzelda Avatar asked Jul 29 '13 15:07

Linkandzelda


1 Answers

Declare android:launchMode="singleTop" inside your Manifest.xml for your parent Activity.

The transition will then change to the default fade out when calling something like:

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    // Respond to the action bar's Up/Home button
    case android.R.id.home:
        NavUtils.navigateUpFromSameTask(this);
        return true;
    }
    return super.onOptionsItemSelected(item);
}

(from: http://developer.android.com/training/implementing-navigation/ancestral.html#NavigateUp)

like image 76
ILadis Avatar answered Nov 15 '22 12:11

ILadis