title: Constantly setting animation on TextView and Constantly changing text on TextView Using “run” Method and Handler
body: <p>I have a string array that contains the string values, it displays on the TextView after some time one by one. It stops on the last index of the array. I want to start again changing the text of the TextView from index zero to last index.</p>
  
  <p>I have an animation that is the applied to the above mentioned TextView. The animation showing its result only once on starting time, after that it does not showing its result.
  Here is my Java code.</p>
  
  <pre><code>Animation animMove;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
  
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      intelStoryTextView = (TextView) findViewById(R.id.intel_story_textview);
  
      doTask();
  
      animMove = AnimationUtils.loadAnimation(getApplicationContext(),
              R.anim.move);
  }
  
  public void doTask() {
  
      final String[] my_string = {"Relief Rally", "OEDC Upgrades ", "US Fed to HIKE ", "Probability "};
      final android.os.Handler handler = new android.os.Handler();
      handler.post(new Runnable() {
  
          int i = 0;
  
          @Override
          public void run() {
              animMove.setRepeatCount(Animation.INFINITE);
              intelStoryTextView.setAnimation(animMove);
              intelStoryTextView.setText(my_string[i++]);
  
              if (i == my_string.length) {
                  i = 0;
                  handler.removeCallbacks(this);
  
              } else {
  
                  handler.postDelayed(this, 1000 * 5);
              }
  
          }
      });
  }
  </code></pre>
  
  <p>Here is my animation code.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;set
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:interpolator="@android:anim/linear_interpolator"
      android:fillAfter="true"&gt;
  
      &lt;alpha
          android:duration="1000"
          android:fromAlpha="0.0"
          android:interpolator="@android:anim/accelerate_interpolator"
          android:toAlpha="1.0" /&gt;
  
      &lt;translate
          android:duration="2000"
          android:fromXDelta="70%p"
          android:toXDelta="0%p"
          /&gt;
  
  &lt;/set&gt;
  </code></pre>