Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8840535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:29:10+00:00 2026-06-14T10:29:10+00:00

In my game, when the user presses the back button, it should bring up

  • 0

In my game, when the user presses the back button, it should bring up the pause menu (as a fragment). When the user presses the back button again, it should close the pause menu. All of this should be done with animations.

@Override
public void onBackPressed()
{
    if (!paused)
    {
        // pause game here

        if (mPauseFragment == null)
        {
            mPauseFragment = new PauseFragment();

            FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
            ft.setCustomAnimations(R.anim.fade_in, R.anim.fade_out, R.anim.fade_in, R.anim.fade_out);
            ft.replace(R.id.pause_container, mPauseFragment, "pauseFragment");
            // Start the animated transition.
            ft.commit();
        }
        else
        {
            getSupportFragmentManager().beginTransaction().show(mPauseFragment).commit();
        }           
    }
    else
    {
        // resume game here
        getSupportFragmentManager().beginTransaction().hide(mPauseFragment).commit();
    }

    paused = !paused;
}

It fades in just fine (but only once), but it doesn’t fade out at all. Please give me a bit of hand, thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:29:11+00:00Added an answer on June 14, 2026 at 10:29 am

    ft.setCustomAnimations gets applied to only that particular fragment transaction. Set your animation to every show hide transaction.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I save a Fragment's state when a user presses the back button,
I am developing a game.if the user presses device back button while playing the
I'm writing a puzzle game. When the user presses the check button, I see
In MMO game user account statistics stored in .dat file. I know this is
I'm making a java game, and when the user presses some keys, the sprite
Im making a game and Im having it so that when the user presses
I am trying to serialize my game data. In case the user presses the
I've got a game that I want to pause whenever the user moves to
I'm trying to clear the Entry widget after the user presses a button using
I have a game where user controls a character (with his finger) and i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.