需要实现的效果参见题目,直接参见Demo:
AnimationsActivity.java
package com.example.androidlistanimationdemo;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import android.app.ListActivity;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.ListAdapter;import android.widget.ListView;import android.widget.SimpleAdapter;public class AnimationsActivity extends ListActivity { private Button button = null; private ListView listView = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_animations); listView = getListView(); button = (Button)findViewById(R.id.button); button.setOnClickListener(new ButtonListener()); } private ListAdapter createListAdapter() { List> list = new ArrayList >(); HashMap m1 = new HashMap (); m1.put("name", "bauble"); m1.put("sex", "male"); HashMap m2 = new HashMap (); m2.put("name", "Allorry"); m2.put("sex", "male"); HashMap m3 = new HashMap (); m3.put("name", "Allotory"); m3.put("sex", "male"); HashMap m4 = new HashMap (); m4.put("name", "boolbe"); m4.put("sex", "male"); list.add(m1); list.add(m2); list.add(m3); list.add(m4); SimpleAdapter simpleAdapter = new SimpleAdapter( this,list,R.layout.item,new String[]{"name","sex"}, new int[]{R.id.name,R.id.sex}); return simpleAdapter; } private class ButtonListener implements OnClickListener{ public void onClick(View v) { listView.setAdapter(createListAdapter()); } }}
新建资源anim文件夹:
list_anim_layout.xml
list_anim.xml
ListView自定义布局文件:
APP主题布局文件:
注意关键字layoutAnimation
这个是对整体布局内部(布局内部所有UI元素---这个非常重要)的元素UI一个一个的显示效果出来.
demo下载:http://pan.baidu.com/s/1bnhIPcV