一、简介

二、代码
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. 使用repeater控件显示列表替代treeview

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...

  2. nginx install in centos

    1.在nginx下载rpm包,如nginx-release-centos-6-0.el6.ngx.noarch.rpm ,并安装(可用yum直接安装): 注:rpm包只是提供一个nginx源. 2.使 ...

  3. ASP.NET 使用C#代码设置页面元素中的样式或属性

    在HTML元素的属性中加上runat ="server"和ID="MyTag"即可在后台代码中通过设置MyTag.Style的值来控制样式. 例如:在前端页面加 ...

  4. java web-----MVC设计模式

    一,MVC将代码分为三个部分,分别为视图(jsp),模型(javaBean),控制部分(servlet); 视图基本为 jsp 文件,主要内容为界面的html代码,负责显示界面: 模型为 javaBe ...

  5. dorado中的creationType选择类型

    新建model层中 DataType类型的时候,有几个属性creationType,matchType时候需要在右侧选择对应的javaBean,这是时候要在弹出的对话框搜索. 此时,只要搜索javaB ...

  6. ZOJ 1122 Clock(模拟)

    Clock Time Limit: 2 Seconds      Memory Limit: 65536 KB You are given a standard 12-hour clock with ...

  7. 九度OJ 1387 斐波那契数列

    题目地址:http://ac.jobdu.com/problem.php?pid=1387 题目描述: 大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项.斐波那契数列的定义 ...

  8. vsftpd.conf配置详解

    根据 /etc/vsftpd/vsftpd.conf默认配置给出设定功能   # Example config file /etc/vsftpd/vsftpd.conf # The default c ...

  9. Linux初始root密码设置

    刚安装好的Linux系统是没有设置root用户密码的,下边介绍如何设置root用户的密码 第一步:sudo passwd 第二步:输入密码 第三步:确认密码 这样三个步骤过后root用户的密码就设置好 ...

  10. MySQL基础学习之视图

    创建新的视图 CREATE VIEW 视图名  AS SELECT  属性,属性1,属性2  FROM 表名 创建新的视图并指定数据名 CREATE VIEW 视图名(新属性,新属性1,新属性2)   ...