title: How can I animate an Android TextView without refreshing it, and fill it each time with new text from an array?
body: <p>I am willing to create a news bar in android application and I used the animation to move TextView from left to right and fill it each round with a new text from array of strings. I faced a lot of problems and I used more than 5 ways but each one has a bad behaviour. the main problem is that when the animation ends it refreshes the textView and it appears like flashing which is not a user-friendly behaviour.</p>
  
  <p>Here is a code snippet:</p>
  
  <pre><code>     TextView my_text;
       Animation slideRight;      
       Animation slideLeft;
       String [] text = {"TwoOneOneOneOneOneOneOneOneOneTwo","OneTwoTwoTwoTwoTwoTwoTwoTwoTwoTwoOne",
          "OneThreeThreeThreeThreeThreeThreeThreeOne","OneFourFourFourFourFourFourFourOne",
          "OneFiveFiveFiveFiveFiveFiveFiveOne","OneSixSixSixSixSixSixSixOne",
          "OneSevenSevenSevenSevenSevenSevenSeveOne","OneEightEightEightEightEightEightEightOne",
          "OneNineNineNineNineNineNineNineOne"};
  
       int arr_length;
       int count = 0;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      arr_length = text.length;
  
      slideRight = AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right);
  
      slideRight.setDuration(2000);
      slideRight.setRepeatCount(Animation.INFINITE);
      slideRight.setAnimationListener(slideRightListener);
      slideLeft = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left);
      slideLeft.setDuration(2000);
      slideLeft.setAnimationListener(slideLeftListener);
  
      my_text = (TextView) findViewById(R.id.textView1);
      my_text.setVisibility(TextView.VISIBLE);
      my_text.setOnClickListener(new OnClickListener() {
          @Override
          public void onClick(View v) {       
              Toast.makeText(getApplicationContext(), my_text.getText(), Toast.LENGTH_SHORT).show();
          }
      });
  
      slideLeft.setAnimationListener(slideLeftListener);
      my_text.startAnimation(slideLeft);
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
  }
  
  AnimationListener slideLeftListener = new AnimationListener() {
  
      @Override
      public void onAnimationStart(Animation animation) {
          my_text.setVisibility(TextView.VISIBLE);
  
      }
  
      @Override
      public void onAnimationRepeat(Animation animation) {
          my_text.setVisibility(TextView.VISIBLE);
  
      }
  
      @Override
      public void onAnimationEnd(Animation animation) {
          my_text.setVisibility(TextView.VISIBLE);
          my_text.startAnimation(slideRight);
      }
  }; 
  
  AnimationListener slideRightListener = new AnimationListener() {
  
      @Override
      public void onAnimationStart(Animation animation) {
          my_text.setVisibility(TextView.VISIBLE);
      }
  
      @Override
      public void onAnimationRepeat(Animation animation) {
          my_text.setVisibility(TextView.VISIBLE);
      }
  
      @Override
      public void onAnimationEnd(Animation animation) {
          my_text.setVisibility(TextView.VISIBLE);
          if(count&lt;arr_length)
          {               
              my_text.setText(text[count]);
              count+=1;
              my_text.startAnimation(slideLeft);
          }
          else
          {
              count=0;
              my_text.setText(text[count]);
              my_text.startAnimation(slideLeft);
          }
  
      }
  }; 
   }
  </code></pre>