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

  • SEARCH
  • Home
  • 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 5840827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:48:20+00:00 2026-05-22T11:48:20+00:00

simple question maybe but can’t find solution. I have button for refresh/update some contents

  • 0

simple question maybe but can’t find solution.

I have button for refresh/update some contents . Button called “refresh”.
In background of this button – i have image. I want to set rotated animation for this image while my content updated . But i have some problem : First – my content updated and only than i can see animation : here is my code :

 Timer myTimer;
    public void timerS()
    {
      myTimer = new Timer();
        myTimer.schedule(new TimerTask() {
            @Override
            public void run() {
                TimerMethod();
            }
        }, 0, 100);
    }
    private void TimerMethod()
    {
        this.runOnUiThread(Timer_Tick);
    }

    private Runnable Timer_Tick = new Runnable() {
        public void run() {
         // drawMatrix();
            animation();
             seconds++;
         }

    };
    int degree =60;
    int oneClick=1;
    public int nowUpdated = 0;
      public void animation()
        {
        int   currentRotation = 0;
            RotateAnimation anim = new RotateAnimation(currentRotation, (360*4),
                    Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,0.5f);
            currentRotation = (currentRotation + 45) % 360;

            anim.setInterpolator(new LinearInterpolator());
            anim.setDuration(10000);
            anim.setFillEnabled(true);

            anim.setFillAfter(true);
            refresh.startAnimation(anim);
        }

i tried to use timer for this. First my example was with drawMatrix – but there i cant fix issue with size of image.. When my image is rotated – Animation is very big. Size of image 32×32.. but when click for updated – i think size of image is 64×64. and can’t fix this
Here code for draw matrix :

public void drawMatrix()
    {
        if(nowUpdated==1)
        {
         Matrix mat = new Matrix();
         degree=degree+45;
         mat.postRotate(degree);
         Bitmap source = BitmapFactory.decodeResource(getResources(),R.drawable.refresh);

         Bitmap a = Bitmap.createBitmap(source, 0, 0,  32 ,  32, mat, true);
         Drawable d =new BitmapDrawable(a);
         refresh.setBackgroundDrawable(d);
        } 
     }

please if anyone can help me – please tell me how to fix first my code or second.
Regards Peter.

  • 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-05-22T11:48:21+00:00Added an answer on May 22, 2026 at 11:48 am

    as discussed in chat: use an AsyncTask to do your update processing (in doInBackground() ) and before starting with the actual processing – call publishProgress() – that will call the AsyncTask method onProgressUpdate (which you’ll have to override) and start your animation there 🙂 – the latter step is necessary, because onProgressUpdate can do UI thread stuff – doInBackground can’t (because it’s not running on the UI thread).

    Cheers,

    Ready4Android

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

Sidebar

Related Questions

Well simple question here (maybe not a simple answer?) Say I have a two
Maybe a simple question but I really don't know what to do. When I
This is maybe a really simple question, but I couldn't locate an answer: For
Simple question, but one that I've been curious about...is there a functional difference between
Simple question: Can a swing frame be completely modal ( block all others windows
Simple question: Can I mix in my desktop application Java and JavaFX Script code?
I have tried to ask a variant of this question before. I got some
Maybe a simple question, I'm trying to get a result from a table where
Maybe a simple question. When I attach to a process, I run continue to
This is probably a simple question, but how do I know when a Storyboard

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.