0

At the outset, I would like to apologize for my English :).

I have a String with long text. I display it in a TextView. If the text is automatically wrapped to new line, I want to add "\t" at the beginning of the new line. I don't know how do it. Any ideas?

E.g.

String text = "1. abcdefghij\n\tklmnopqrstuvwxyz";

Display:
1. abcdefghij
   klmnopqrstuvwxyz

But if:

String text = "1. abcdefghij\n\tklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

Display:
1. abcdefghij
   klmnopqrstuvwxyzABCDEF
GHIJKLMNOPQRSTUVWXYZ

I want:

1. abcdefghij
   klmnopqrstuvwxyzABCDEF
   GHIJKLMNOPQRSTUVWXYZ
Dżordż55
  • 11
  • 1
  • 5

1 Answers1

0

You can count the lines of your TextView and if there are more than 1 insert a "\t".

In this post it's shown how to count the lines although is not an obvious question.

You also need to take into account if the tab is already inserted, because could be inserted more than one \b.

Community
  • 1
  • 1
sergiomse
  • 775
  • 12
  • 18
  • This is my code: http://pastebin.com/Dg5apb4F In array "test" are the lines of text. Run() should write out the "Get Count." after each "Number of lines:...", but Run() work only after all, like in link. Xxxxx is my lines of text, which is well printed. – Dżordż55 Aug 31 '14 at 19:46