如何在动画TextView的文本改变?

如何在动画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 - 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正是你应该使用这个东西。退房的API演示的TextSwitcher 。

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

您应该实现这一点的方法是在你的ListAdapter,提供TextSwitcher意见到ListView,而不是TextViews。然后,你可以叫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.