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 7757173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:00:59+00:00 2026-06-01T13:00:59+00:00

I need help with Android. I’m trying to create a slot machine game. So,

  • 0

I need help with Android.
I’m trying to create a slot machine game. So, I’m using the AnimationDrawable for the three wheels. Here is the animwheel.xml file:

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/animWheel"
android:oneshot="false" >

<item
    android:drawable="@drawable/fruits1"
    android:duration="200"/>
<item
    android:drawable="@drawable/fruits2"
    android:duration="200"/>
<item
    android:drawable="@drawable/fruits3"
    android:duration="200"/>
</animation-list>

I putted the animation-list in 3 different views (the three whells) in the main layout using the attribute android:background

android:background="@drawable/animwheel"

Now, the user can stop the animations by clicking on three different buttons. The problem is how can I know which is the picture that the view is displaying currently?
Is there any getCurrentFrame() method or something like that?

Thank you in advance!

  • 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-01T13:01:00+00:00Added an answer on June 1, 2026 at 1:01 pm

    I have the same problem, tried every function, and don’t have success because the functions like ‘getCurrentFrame()’ returns a hexadecimal value that changes every time you run your application, so, I did something that resolve my problem, and hope that resolves yours:

    Instead of trying to get the name of image of the frame (‘fruits1’), you have to get the position of the frame, supose that user stoped animation in frame ‘fruits2’, so, the number of the frame is 1, because 0 is the frame ‘fruits1’. How will you do that?

    // Create the animation
    myImage.setBackgroundResource(R.anim.myanimation);
    myAnimation = (AnimationDrawable) myImage.getBackground();
    

    When you stops the animation you do something like this:

    myAnimation.stop();
    
    // The variable that will guard the frame number
    int frameNumber;
    
    // Get the frame of the animation
    Drawable currentFrame, checkFrame;
    currentFrame = myAnimation.getCurrent();
    
    // Checks the position of the frame
    for (int i = 0; i < myAnimation.getNumberOfFrames(); i++) {
        checkFrame = myAnimation.getFrame(i);
        if (checkFrame == currentFrame) {
            frameNumber = i;
            break;
        }
    }
    

    So, the variable ‘frameNumber’ will guard the number of the frame, in your case, 0, 1, or 2.
    If will have a lot of frames, you could do a function that return the name (‘fruits1’, ‘fruits2’ …) based on the number of the frame, using an array.

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

Sidebar

Related Questions

I need help... I got errors with my android xml... Here's the code: <?xml
I need some help dealing with three Threads in Android One thread is the
need help to create regular expression matching string www.*.abc.*/somestring Here * is wild card
i need help.. i'm trying to call php webservices from my android client application
I need some help on android.., apparently, I'm trying to make a progress dialog
Hi all I am making a game for Android and I need help placing
I need some help to store a Object in an SQLite database using Android.I
I need a little help with Android Shared Preferences. I'm trying to put a
I need help on encryption/decryption on Android application. I explain the situation. I'm actually
I need help to find the correct command, on android, to remove the blue

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.