2015-05-27 11 views
0

請快速提問。Android回車內串連字符串

我讀NFC標籤和顯示我的設備的屏幕上的結果,這是如何出現的:

The content of the tag is : bla bla bla 

我想有2行顯示爲這樣:

The content of the tag is : 

bla bla bla 

我加

android:singleLine="false" 

TextView的定義中,但現在雖然我有2行,它不是切,我想這是因爲我得到這個:

The content of the tag is : bla 

bla bla 

很多周圍的人談論\n\r,但我不明白如何將其整合我的TextView裏面,因爲它是一個串聯:

TextView.setText("The content of the tag is : " + result); 

任何提示?乾杯

回答

1

嘗試用

TextView.setText("Tag is :\n" + result); 

或者在必要

TextView.setText("Tag is :\n" + result.replaceAll("[^\\w]+", " ")); 

它只是替換任何組特性而不是一個空格字母或數字的。

+0

嗨Mederic,它不適合我,因爲它不會把我的痘痘放在第二行。任何想法爲什麼不呢? PS:它所做的就是你說的。我的時間從10:50:22到10 50 22,如果我把表情符號不顯示它們。 – Clararhea

+0

嗨Clarahea。我更新了我的答案。希望它有助於 –

+0

nope,我也試過\ r然後\ n \ r。到目前爲止沒有做任何事情 – Clararhea