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)
To start the animation we need to call the startAnimation() function on the UI element as shown in the snippet below: sampleTextView. startAnimation(animation); Here we perform the animation on a textview component by passing the type of Animation as the parameter.
TextView tv1 = (TextView)findViewById(R. id. textView1); tv1. setText("Hello"); setContentView(tv1);
Set The Text of The TextView You can set the text to be displayed in the TextView either when declaring it in your layout file, or by using its setText() method. The text is set via the android:text attribute.
If you want to show a strike-through text you can do it programming using PaintFlags. You can set paint flags Paint. STRIKE_THRU_TEXT_FLAG to a TextView and it will add a strike-through to the text. TextView textView = (TextView) findViewById(R.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With