13

Trying to do the following:

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?

(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)

1 Answer 1

14

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

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.

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

Sign up to request clarification or add additional context in comments.

3 Comments

thanks for your reply. Have you seen my question with TextSwitcher code? It doesn't work properly and I can not understand why.
@LA_ I did. I added an answer that explains why this is happening.
Can I use TextSwitcher to animate Toolbar title changes or is there a better way?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.