I am currently trying to solve a java based problem on Android Studio.
I have puzzled my head over this problem looking in many forums and webpages to not find any solution in the last two days. So I am seeking for help here now.

I have programmed a Button that when clicked causes a textview to swipe out of the screen with an animation. After that I would like the old text ("First Text") of the Textview to be replaced with another text ("New Text") appearing on the same place where the old text was. All of this should happen with only one click on the button step-after-step.

My problem with my code is that the old text is replaced by the new text first and then causes the animation.

Does anybody now a solution for this problem?

I would be really very grateful for any help!

This is my code below.

```
public class FirstActivity extends AppCompatActivity {

    Animation slideleft;
    Button btn1;
    TextView txt1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.first_layout);

        btn1 = (Button) findViewById(R.id.btn1);
        txt1 = (TextView) findViewById(R.id.txt1);

        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                slideleft = AnimationUtils.loadAnimation(FirstActivity.this, R.anim.slide_left);

                txt1.startAnimation(slideleft);

                txt1.setText("New Text");

    }
        });
    }
}

```