ANDROID_MARS学习笔记_S02_011_ANIMATION_LayoutAnimationController
一、简介



二、代码
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的更多相关文章
- ANDROID_MARS学习笔记_S01_012_RatingBar
1.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns: ...
- ANDROID_MARS学习笔记_S01_012_SeekBar
1.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns: ...
- ANDROID_MARS学习笔记_S01_011ProgressBar
文档是这样来设置样式 <ProgressBar android:layout_width="wrap_content" android:layout_height=" ...
- ANDROID_MARS学习笔记_S01_010日期时间控件
1.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns: ...
- ANDROID_MARS学习笔记_S01_009Relative_LAYOUT例子
1. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android ...
- ANDROID_MARS学习笔记_S01_008Linear_layout例子
1.netstone_layout.xml <?xml version="1.0" encoding="utf-8"?> <LinearLay ...
- ANDROID_MARS学习笔记_S01_007Linear_layout嵌套与layout_weight的设置
一.介绍 二.1.linear_layout.xml <?xml version="1.0" encoding="utf-8"?> <Line ...
- ANDROID_MARS学习笔记_S01_006ImageView
一.ImageView介绍 设置scalType Must be one of the following constant values. Constant Value Description ma ...
- ANDROID_MARS学习笔记_S01_005CheckBox
一. 1.checkbox_layout.xml <?xml version="1.0" encoding="utf-8"?> <Linear ...
随机推荐
- oc语言学习之基础知识点介绍(一):OC介绍
一.第一个OC程序 #import <Foundation/Foundation.h> //导入头文件 int main(int argc, const char * argv[]) ...
- 【html】【8】div布局[子div在父div居底]
从今天起 开始细话div布局 思路及要点: 父div的位置设置成相对的,即“position: relative;”. 而子div的位置设置成绝对的,并且下边缘设为0,即“position: ab ...
- Jquery-Mobile滚动事件
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> < ...
- ubuntu获取硬盘的uuid。
1.用UUID来标识硬盘有很多好处,它是一个硬盘的唯一代号,所以当硬盘插口位置变化时,虽然sda可能会变成sdc,但这个码是不会变的.所以在 fstab中用/dev/sda1这样的硬盘标识可能会有混乱 ...
- 一台Ubuntu server上安装多实例MySQL
受环境所迫,在一台Ubuntu server上安装多个实例MySQL. 手动安装MySQL 环境:Ubuntu server 11.10 64bit + mysql-5.5.17-linux2.6-x ...
- ASP.Net MVC 生成安全验证码
---------html <td>验证码:</td> <td> <img src="/Logi ...
- IT书籍下载汇总--持续更新
本书单由北北分享,并持续更新,请将该地址加入收藏夹:北北的书单 .badge{float:right;}.list-group-item > .badge + .badge{margin-rig ...
- 《Junit实战》读书笔记
核心原则:任何没有经过自动测试的程序功能都可以当做不存在 单元测试框架的大三规则: 1.每个单元测试都必须独立于其他所有单元测试而运行 2.框架应该以单个测试为单元来检测和报告错误 3.应该易于定义要 ...
- python基础学习(二)--函数
return返回值: python函数都有返回值,函数体内无return,默认返回值None, 函数参数: 1.普通参数 严格按照顺序,将实际参数赋值给形式参数,一一对应. 例: def send(x ...
- sublime c++ builder
rt, mark { "cmd": ["g++", "${file}", "-o", "${file_path ...