一、简介

二、代码
1.xml
(1)activity_main.xml

 <ListView
android:id="@id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="vertical"
/>
<!-- android:layoutAnimation="@anim/list_anim_layout" --> <Button
android:id="@+id/buttonId"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="测试"
/>

(2)item.xml

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="horizontal" android:paddingLeft="10dip"
android:paddingRight="10dip" android:paddingTop="1dip"
android:paddingBottom="1dip"> <TextView android:id="@+id/user_name" android:layout_width="180dip"
android:layout_height="30dip" android:textSize="5pt"
android:singleLine="true"/>
<TextView android:id="@+id/usr_gender" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:textSize="5pt"
android:singleLine="true"/>
</LinearLayout>

(3)res\anim\list_anim.xml

 <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:shareInterpolator="true"> <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="2000" />
</set>

(3)res\anim\list_anim_layout.xml

 <?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:delay="2"
android:animationOrder="normal"
android:animation="@anim/list_anim" />

2.java
(1)MainActivity.java

 package com.layoutanimationcontroller;

 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.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LayoutAnimationController;
import android.widget.Button;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter; public class MainActivity extends ListActivity { private Button button = null;
private ListView listView = null; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listView = getListView();
button = (Button)findViewById(R.id.buttonId);
button.setOnClickListener(new ButtonListener());
} class ButtonListener implements OnClickListener {
@Override
public void onClick(View v) {
listView.setAdapter(buidListAdapter());
Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.list_anim);
LayoutAnimationController lac = new LayoutAnimationController(animation);
lac.setOrder(LayoutAnimationController.ORDER_NORMAL);
lac.setDelay(0.5f);
listView.setLayoutAnimation(lac);
}
} private ListAdapter buidListAdapter() {
List<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>();
HashMap<String, String> m1 = new HashMap<String,String>();
m1.put("user_name", "张三");
m1.put("user_gender", "女"); HashMap<String, String> m2 = new HashMap<String, String>();
m2.put("user_name", "李四");
m2.put("user_gender", "女"); HashMap<String, String> m3 = new HashMap<String, String>();
m3.put("user_name", "王五");
m3.put("user_gender", "男"); list.add(m1);
list.add(m2);
list.add(m3); SimpleAdapter simpleAdapter = new SimpleAdapter(this, list, R.layout.item,
new String[] {"user_name", "user_gender"},
new int[] {R.id.user_name, R.id.usr_gender});
return simpleAdapter;
}
}

ANDROID_MARS学习笔记_S02_011_ANIMATION_LayoutAnimationController的更多相关文章

  1. ANDROID_MARS学习笔记_S01_012_RatingBar

    1.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns: ...

  2. ANDROID_MARS学习笔记_S01_012_SeekBar

    1.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns: ...

  3. ANDROID_MARS学习笔记_S01_011ProgressBar

    文档是这样来设置样式 <ProgressBar android:layout_width="wrap_content" android:layout_height=" ...

  4. ANDROID_MARS学习笔记_S01_010日期时间控件

    1.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns: ...

  5. ANDROID_MARS学习笔记_S01_009Relative_LAYOUT例子

    1. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android ...

  6. ANDROID_MARS学习笔记_S01_008Linear_layout例子

    1.netstone_layout.xml <?xml version="1.0" encoding="utf-8"?> <LinearLay ...

  7. ANDROID_MARS学习笔记_S01_007Linear_layout嵌套与layout_weight的设置

    一.介绍 二.1.linear_layout.xml <?xml version="1.0" encoding="utf-8"?> <Line ...

  8. ANDROID_MARS学习笔记_S01_006ImageView

    一.ImageView介绍 设置scalType Must be one of the following constant values. Constant Value Description ma ...

  9. ANDROID_MARS学习笔记_S01_005CheckBox

    一. 1.checkbox_layout.xml <?xml version="1.0" encoding="utf-8"?> <Linear ...

随机推荐

  1. 一个ASP函数库

    <% '****************************** '类名: '名称:通用库 '日期:2008/10/28 '作者:by xilou '网址: '描述:通用库 '版权:转载请注 ...

  2. C#学习笔记12:枚举、结构、数组基础学习

    枚举:public enum MyEnum { 值1, 值2, 值3 } Public enum Season { 春, 夏, 秋, 冬 } 枚举的作用:规范用户的输入,枚举可以转换为int类型,可以 ...

  3. Microsoft SQL Server Product Samples:Database

    从SQL Server 2005 之后示例数据都为AdventureWorks,需要的通过codeplex网站下载.这样设计的目的应该在于是生产库行不必要的用户以及权限分配. 从以下网址访问http: ...

  4. Python获取本机的mac,ip,name

    Python获取mac 获取计算机名字和ip(内网ip) 指定网卡ip

  5. MVC3中 swfupload 按钮不显示 解决方案

    这两天在做图片上传并显示的功能,之前就用过swfupload,觉得很不错,之前是用asp.net webform做的,这次的项目是用asp.net MVC3来做,视图引擎用的是Razor. 将js文件 ...

  6. jquery个人笔记

    一.链式操作 <!DOCTYPE html> <html> <head> <title></title> <script src = ...

  7. HDU分类

    原地址:http://www.byywee.com/page/M0/S607/607452.html 总结了一下ACM STEPS的各章内容,趁便附上我的Steps题号(每人的不一样). 别的,此文首 ...

  8. 九度OJ 1366 栈的压入、弹出序列 【数据结构】

    题目地址:http://ac.jobdu.com/problem.php?pid=1366 题目描述: 输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序.假设压入栈的 ...

  9. opcache运行时配置参数详解

    PHP的opcode缓存又出 了新成员(说新不新,也有一段日子了),那就是opcache.新浪微博等都在使用,惠新宸老师强力推荐.本人最近根据官网地址 (http://www.php.net/manu ...

  10. MVC 中 使用TagBuilder扩展HtmlHelper

    TagBuilder就是标签建造器,我们就用它来建造属于我们自己标签生成函数. 无废话,直接上代码 例: using System.Web.Mvc; public static class HtmlE ...