Vlad Alexeev
Vlad Alexeev

Reputation: 2204

String - "break line" aka "paragraph line"

This should be simple, but I can't find how to solve it.

I need something that called "break line", "paragraph line" in typography, simply 4 or 5 spaces before text at the beginning of new paragraph.

I also need to store strings (string-array) in resources because it will be multy-lingual app.

all the text in resources looks like :

<item><![CDATA[TextTextText TextTextTextTextText.<br /><br />]]></item>

So, If I place 5 spaces before first letter of Text itself - Android will ignore them as it should. I thought - "ok, I'll make some char combination that I will later replace with spaces.Let's say "lNNl".

so I did : (resources)

<item><![CDATA[lNNlTextTextText TextTextTextTextText.<br /><br />
lNNl TExttext<br />]]></item>

(code)

for (int i=0;i<tv_id.length;i++){ 
 tv[i]=(TextView)  view.findViewById(tv_id[i]);
String tabbedString=conversations[i].replaceAll("lNNl", "    ");//lNNl is what I want to replace
          Spanned sp=Html.fromHtml(tabbedString);
         tv[i].setText(sp);

Aaaaaand.. Spaces at the beginning of the line are ignored again.

I understand that it should be solved simply..somehow .. but can't find a way

Upvotes: 1

Views: 153

Answers (1)

Phant&#244;maxx
Phant&#244;maxx

Reputation: 38098

Use

String tabbedString=conversations[i].replaceAll("lNNl", "&nbsp;&nbsp;&nbsp;&nbsp;");

Upvotes: 1

Related Questions