一、简介

二、代码
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. 解决IllegalStateException: Can not perform this action after onSaveInstanceState:

    今天做项目中的支付宝功能,是在fragment中做的,在支付成功后,想切换到支付成功的页面. 结果就报错了IllegalStateException: Can not perform this act ...

  2. oc语言学习之基础知识点介绍(五):OC进阶

    一.点语法介绍 /* 以前封装后,要给属性赋值,必须调用方法 这样做,有两个缺点: 1.代码量多,调用方法要写的东西多. 2.看起来并不像是给属性赋值,也不像取值. 我们用点语法就可以更好的解决! 点 ...

  3. WinForm程序中两份mdf文件问题的解决

    在项目中用程序中嵌入mdf文件的方式来进行SQLServer数据库开发非常方便,用来发布开源项目等很方便,点击就可以运行,免部署,特别是在教学中用起来更加方便,老师不用先将数据库文件detach再发给 ...

  4. MongoDB使用记录

    安装服务 使用以下命令将MongoDB安装成为Windows服务.笔者的MongoDB目录为D:\Program Files\mongodb mongod --logpath "D:\Pro ...

  5. 2016/01/19 javascript学习笔记-name属性

    1. name属性只在少数html元素中有效:包括表单.表单元素.<iframe>和<img>元素. 基于name属性的值选取html元素,可以使用document对象的get ...

  6. mysql---整体备份和增量备份

    整体备份: 对整张表或者整个数据库甚至所有数据库进行备份. 增量备份: 对某一范围内的数据进行备份. 1.整体备份: 对表进行备份: 针对存储引擎为myisam的表,可以直接复制frm.myd.myi ...

  7. Linux内核Radix Tree(三):API介绍

    1.     单值查找radix_tree_lookup 函数radix_tree_lookup执行查找操作,查找方法是:从叶子到树顶,通过数组索引键值值查看数组元素的方法,一层层地查找slot.其列 ...

  8. html标签对应的英文原文

    标签 对应英文 说明 <!--> / 注释 <!DOCTYPE> document type 文档类型 <a> anchor 超链接 <abbr> ab ...

  9. postal.js使用

    requirejs.config({ //默认情况下模块所在目录为js/lib baseUrl: './', //当模块id前缀为app时,他便由js/app加载模块文件 //这里设置的路径是相对与b ...

  10. mysql触发器的例子--插入前更新数据

    本文介绍下,一个mysql触发器的例子,在数据插入前更新相关内容,有需要的朋友参考下. mysql触发器的例子,如下: view source print? 001 mysql> CREATE  ...