How to add text every 1 second to old text in TextView

i'm trying to add text every 1sec to old text in TextView let me explain more

for example in first time i have in TextView this text :

Hello 1

after 1sec must be added to another text like this

Hello 1

Hello 2

and after 1sec

Hello 1

Hello 2

Hello 3

this is my code :

Texthack = (TextView)findViewById(R.id.hacktext);
    Handler Timer = new Handler();
    int i = 0;
    for (int j = 1; j<=1000 ;j++) {
        i++;
        final int finalI = i;
        Timer.postDelayed(new Runnable() {
            @Override
            public void run() {
                Texthack.setText("Hello "+ finalI +"\n");
            }
        }, 1000);
    }
}
}

please help me

Upvotes: 0

Views: 61

Answers (2)

toonvanstrijp
toonvanstrijp

Reputation: 417

Now your replacing the current text by your new text. You have to change this line:

Texthack.setText("Hello "+ finalI +"\n");

To

Texthack.append("Hello "+ finalI +"\n");

Upvotes: 0

Related Questions