列表视图和动画
问题描述:
我使用的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.