gpt4 book ai didi

android - ListView 和动画

转载 作者:行者123 更新时间:2023-11-29 18:20:43 25 4
gpt4 key购买 nike

我正在使用 API DEMOS 中的 ListView 动画,示例 2。这是 OnCreate 方法的 fragment :

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() 被调用到列表的适配器上,我的列表被刷新。但这些项目不再显示在动画中。

请帮忙。

最佳答案

如果你想在你的数据集改变后重新激活你的 LayoutController,调用方法 startLayoutAnimation()的观点。

关于android - ListView 和动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5678661/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com