列表视图和动画 [英] Listview and animation

查看:135
本文介绍了列表视图和动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的ListView动画从API演示,例如2.下面是从onCreate方法的代码片段:

I'm using listview animation from API DEMOS, example 2. here's the snippet from OnCreate method:

ListView listview = (ListView) findViewById(android.R.id.list);

AnimationSet set = new AnimationSet(true);
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(50);
set.addAnimation(animation);

animation = new TranslateAnimation(
    Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
    Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f);

animation.setDuration(200);
set.addAnimation(animation);

LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
listview.setLayoutAnimation(controller);

在未来的某个时候, notifyDataSetInvalidated()是在列表的接口调用,并且我的列表刷新。但项不会在动画中显示的任何更多。

At some point in the future, notifyDataSetInvalidated() is called upon list's adapter, and my list is refreshed. but the items are not shown in animation any more.

请帮忙。

推荐答案

如果你想你复活后LayoutController数据集的变化,调用该方法的 startLayoutAnimation()的看法。

If you want to reanimate your LayoutController after your data set changes, call the method startLayoutAnimation() of the view.

这篇关于列表视图和动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆