Android settings after the ListView data is loaded to execute layoutanimation

Source: Internet
Author: User

Today uses Android's volley framework to write a simple web weather capture demo.

The space that hosts the data is the ListView

Because is the network load, must first set the ListView the default data, I set is that loading ...

The data is then retrieved from the network, then parsed, then updated to adapter, and then notifydatasetchanged updated to the ListView.

However, the ListView is set to Layoutanimation, so that the default ListView opens after the loading performed the animation, when the network data load is complete,

The layoutanimation will not be executed again!

Online search without fruit, may be novice, not too familiar, sent to the CSDN also no one answered me!

Finally, my own research found that the use of XML is the way set layoutanimation, so the ListView after loading began to execute!

< ListView         Android:layout_width = "Match_parent"         android:layout_height= "Match_parent"        android:id= "@+id/listview"         android:layout_centervertical= "true"        android:layoutanimation= "@anim/list_anim_layout2"        android:layout_centerhorizontal= "true"/> 

Then think of code execution animation, first load all animation, then the network data is loaded and updated to the ListView and then bind animation to the ListView.

1 PrivateLayoutanimationcontroller Lac;2 3 //--@ Load the listview layoutanimation animation4Lac=animationutils.loadlayoutanimation (weatheractivity. This, r.anim.list_anim_layout2);5 6 //After response7 .......8 //--@ Update data to ListView9 adapter.notifydatasetchanged ();Ten //--Set Layoutanimation to perform animation after loading is complete OneListvview.setlayoutanimation (LAC);

This realization of the predetermined function, beginners unfamiliar is a variety of tangled, not sure to turn to that corner of the turn can not come out ...!

[Email protected] January 28 11:31:25-if not strong, cowardly to whom to pity!

Android settings after the ListView data is loaded to execute layoutanimation

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.