:
Usually we want to achieve the ListView data display animation effect, you can use Layoutanimationcontroller to animate the ListView, and through the Setlayoutanimation method of the ListView to set, Finally Startlayoutanimation, start the animation. See the following code:
public class Mainactivity extends Activity {private ListView lv_arrayadapter;private string[] str_name = new string[] {"J Ack "," Debb "," Robin "," Kikt "," Dog "," cat "," Elep "}; @Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview ( R.layout.activity_main); Initview (); SetData (); Loadanimation ();} private void Loadanimation () {/* * Creates a collection of animations */animationset set = new Animationset (false); Animation Animation; */* Create a rotation animation */animation = new Rotateanimation (+); animation.setduration (1000); Set.addanimation (animation); Layoutanimationcontroller controller = new Layoutanimationcontroller (set, 1); Controller.setinterpolator (This, Android. R.anim.accelerate_interpolator); controller.setanimation (set); Lv_arrayadapter.setlayoutanimation (Controller); LV _arrayadapter.startlayoutanimation ();} private void Initview () {lv_arrayadapter = (ListView) Findviewbyid (r.id.lv_arrayadapter);//Register Listener event Lv_ Arrayadapter.setonitemclicklistener (New OnitemclicKlistener () {@Overridepublic void Onitemclick (adapterview<?> parent, View view,int position, long ID) { Toast.maketext (Mainactivity.this, Str_name[position],toast.length_short). Show ();}}); private void SetData () {//create arrayadapterarrayadapter<string> Arrayadapter = new Arrayadapter<string> ( Mainactivity.this, Android. R.layout.simple_list_item_1,str_name);//Bind adapter Lv_arrayadapter.setadapter (Arrayadapter);}}
Activity_main.xml:
<relativelayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools " android:layout_width=" match_parent " android:layout_height=" Match_parent " > <listview android:id= "@+id/lv_arrayadapter" android:layout_width= "Fill_parent " android:layout_height= "Wrap_content" > </ListView> </RelativeLayout>
Reprint Please specify the Source:http://blog.csdn.net/hai_qing_xu_kong/article/details/44248637Emotional Control _
Learn about Android settings ListView data Display animation effect (24)