0

I am developing an calculator app. That app take input using edit text and shows the value in a textview using setText. Some times the input get bigger and it becomes hard to fit the output in a single line. That's why I need to spilt the output into multiple line. I've used some line separator solutions from SO but nothing properly works for me.

Please give me a solution to show a way to show the output text into multiple line. Please don't flag as similar .
Note: All my input and output are number and they have no space or punctuation mark in them.

Thanks in Advance.

1 Answers1

0

Im not allowed to comment yet. So have u heard of "Spanned"? Im Using kotlin and Assuming max items in one line is 20 . Try This:

    String yourString  = "1010101110001101011010011100111000111100001110000";
    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append(yourString);

    for(int i = 0; i<yourString.length();i++){
        if(i%20 == 0){
            stringBuilder.insert(i,"<br/>");
        }
    }
    Spanned spannedString = Html.fromHtml(stringBuilder.toString());

    yourtextView.setText(spannedString);

feel free to give feedback.

Rinat Diushenov
  • 1,335
  • 5
  • 11