2014-02-19 72 views
-3

我正在研究android中的項目。我想用/n創建一個新段落。但是我沒有按預期得到結果。是否有其他方法可以創建新行?如何在Android中創建新行?

我的代碼如下

tv.setText("Some of the symptoms of cataract include:/n1.Cloudy, blurry or foggy vision/n2. Development of short-sightedness in older people/n3. Seeing colors differently./n3. Problems with glare during the day or night/n4. Double vision/n5. Sudden changes in prescription of glasses"); 
+3

它應該是'\ N' – guptakvgaurav

+0

感謝ü親愛的! ! – NeoMatrix

回答

7

使用\n代替。你的斜線是在錯誤的方向。它必須是後面的斜槓。

4

\n此時在文本中插入換行符。

因此,使用\n代替/n

2

試試這個:)

System.getProperty("line.separator") 

例如:

TextView textView=(TextView)findViewById(R.id.textView1); 
     textView.setText("Hello"+System.getProperty("line.separator")+"World!!!");