如何在动画TextView的文本改变? [英] How to animate text change in TextView?

查看:126
本文介绍了如何在动画TextView的文本改变?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图做到以下几点:

animTimeChange = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left); 
itemTime.startAnimation(animTimeChange);
itemTime.setText("new text");

但动画发生直通黑屏(即原始文本清除后,新的文本显示动画)。如何避免黑屏?

but the animation happens thru blank screen (i.e. original text is cleared, then new text appears with animation). How to avoid that blank screen?

(我的的TextView 的ListView 行的一部分,我试图用 TextSwitcher - <一个href=\"http://stackoverflow.com/questions/6101470/how-to-correctly-use-textswitcher-in-listview/6240183#6240183\">it工作不正常的;对于 ViewFlipper - 我不知道哪里补充意见存在,因为这是的ListView的一部分)

(my TextView is part of ListView row, I've tried to use TextSwitcher - it doesn't work properly; for ViewFlipper - I am not sure where add Views there, since this is part of the ListView)

推荐答案

TextSwitcher正是你应该使用这个东西。退房的<一个href=\"http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/TextSwitcher1.html\">API演示的TextSwitcher 。

TextSwitcher is exactly what you should be using for this. Check out the API Demo for TextSwitcher.

您应该实现这一点的方法是在你的ListAdapter,提供TextSwitcher意见到ListView,而不是TextViews。然后,你可以叫<一个href=\"http://developer.android.com/reference/android/widget/TextSwitcher.html#setText%28java.lang.CharSequence%29\">TextSwitcher.setText()在列表项要更改。

The way you should implement this is in your ListAdapter, provide TextSwitcher views to the ListView instead of TextViews. Then you can just call TextSwitcher.setText() on the list item you want to change.

请注意,你应该imediately摆脱你参考以列表项,以避免真正搞乱列表视图。

Note that you should imediately get rid of your reference to the list item to avoid REALLY messing up listview.

这篇关于如何在动画TextView的文本改变?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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