Android image loading in wait for animation

Source: Internet
Author: User

XML code
    1. Add a imageviw and a edittext to the layout.
XML code
  1. <ImageView
  2. android:id="@+id/loading_imageview_info"
  3. android:layout_width="wrap_content"
  4. android:layout_height="wrap_content"
  5. android:layout_gravity="center"
  6. android:background="@anim/loading" />
  7. <EditText
  8. android:id="@+id/loading_edittext_info"
  9. android:layout_width="0DP"
  10. android:layout_height="0DP" />

Java code
    1. <pre class="java" name="code" > private ImageView loadingimageview;
    2. private EditText Loadingedittext;
    3. Private animationdrawable anim;</pre>
Java code
    1. Loadingimageview = (ImageView) Findviewbyid (r.id.loading_imageview_info);
    2. Loadingedittext = (EditText) Findviewbyid (r.id.loading_edittext_info);
    3. Loadingedittext.setinputtype (Inputtype.type_null); //Shielded soft keyboard
    4. Anim = (animationdrawable) loadingimageview.getbackground ();
    5. Loadingedittext.setonfocuschangelistener (Editsetonfocus);

Java code
  1. /**
  2. * When the input box gets focus, the animation is run
  3. */
  4. private Onfocuschangelistener Editsetonfocus = new Onfocuschangelistener () {
  5. @Override
  6. public void Onfocuschange (View V, boolean hasfocus) {
  7. //TODO auto-generated method stub
  8. Anim.start ();
  9. LOG.I ("text", "execution wait Animation .....")  ");
  10. }
  11. };

When the program gets to the data the general situation is to send a message in Hanlder to notify the animation to stop and hide the current control

Java code
    1. Anim.stop ();
    2. Loadingimageview.setvisibility (View.gone);

The Anim animation is defined in XML with the following code:

Java code
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <animation-list android:oneshot="false" xmlns:android="Http://schemas.android.com/apk/res/android" >
  3. <item android:duration= "android:drawable="@drawable/load1 "/>
  4. <item android:duration= "android:drawable="@drawable/load2 "/>
  5. <item android:duration= "android:drawable="@drawable/load3 "/>
  6. <item android:duration= "android:drawable="@drawable/load4 "/>
  7. <item android:duration= "android:drawable="@drawable/load5 "/>
  8. <item android:duration= "android:drawable="@drawable/load6 "/>
  9. </animation-list>

Android image loading in wait for animation

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.