Android Development step by step in the process of 52:asynctask custom rotating chrysanthemums

Source: Internet
Author: User



Asynctask in the process, we will generally use a rotating "chrysanthemum" to show the current user's current progress, generally, we do not use the system comes with the ProgressDialog, but the design of their own animation to achieve, when the chrysanthemum rotation, do not allow users to click on the page, So put this chrysanthemum on the alertdialog custom page, if the rotation process, allowing users to click Other locations of the page, such as search the city, then put this progress picture directly on the page XML the file is ready. Give the turning Chrysanthemum implementation Code :)

     first step: Animation Span style= "Font-family:times new Roman" >anim file added rotate_animation.xml

<? xml &NBSP; version = " 1.0 " &NBSP; = " utf-8 " ?>

< rotate &NBSP; xmlns: Android = " http://schemas.android.com/apk/res/android "  

      android:pivotx = " 50% " &NBSP; = " 50% " &NBSP;

  &NBSP;&NBSP;&NBSP, android:fromdegrees Span style= "Color:rgb (0,0,0); Font-family:consolas ">= " 0 " &NBSP; = " -720 "

android:duration="1800"

android:fillafter="true"

android:interpolator="@android: Anim/linear_interpolator"

>

</ Rotate >

Step two: Animate imageview

&NBSP;&NBSP;&NBSP;&NBSP; private &NBSP; void  startanimation (View  view)  {

        animation animation =  Animationutils. loadanimation (citysettingactivity. this , r.anim. rotate_animation

Animation.setrepeatcount (animation. INFINITE );

Animation.setrepeatmode (animation. RESTART );

View.startanimation (animation);

}

Step three: Add turning chrysanthemum in Asynctask

OnPreExecute () inside

Open animation

startanimation (imgprogress);

OnPostExecute () Inside

Turn off animations

imgprogress . clearanimation ();

Android Development step by step in the process of 52:asynctask custom rotating chrysanthemums

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.