Search code examples
javaandroidtextviewsettext

android Java how can I add new textline from TextView


I have a TextView. and firstly I set a line via for loop. array[0], array [1]... at the first time textView has "work", and then I want to add "is", "a" like these strings. However, each time old line deleted and set new line!!!

             inputs2 = inputs.getText().toString();
             String[] words = inputs2.split(",");

             int n= words.length;
             for(int i=0;i<n;i++){
                 resultView.setText(words[i]);

             }

How can I add new textline without deleted old one. Thanks.


Solution

  • To append String values to a TextView, you can use the append() method:

    String [] array;
    TextView textView;
    
    for (int i = 0; i < array.length; i++) {
        textView.append(array[i]);
    }