2014-04-08 14 views
0

在我的Android應用我插入:Android的Eclipse的拆分換行符

Log.i("myApp1", response.toString()); 

這是logcat的Eclipse中的輸出response.toString:

04-08 20:54:21.674: I/myApp1(9930): 23/03/2014<br />Pics 1<br /><br /><br />09/03/2014<br />Pics 2<br /><br /><br /> 

我如何獲得這個輸出在佈局android?我需要嘗試拆分< BR />沒有成功...

23/03/2014 

Pics 1 

09/03/2014 

Pics 2 

回答

0

代替<br />這是你的代碼的HTML代碼中使用\n

String editedResponse = response.replaceAll("<br />", "\n"); 
Log.i("MyApp1", editedResponse); 

如果要在TextView中顯示該字符串,請確保將android:lines設置爲2或更大。

<TextView 
    android:id="@+id/txtTitlevalue" 
    android:text="Line1: \n-Line2\n-Line3" 
    android:layout_width="54dip" 
    android:layout_height="fill_parent" 
    android:lines="2" 
    android:textSize="11px" /> 
+0

好的,謝謝。現在我有這個輸出'23/03/2014'如何在layout android中設置textView的值? – comex

+0

在你的TextView和你的代碼中使用android:lines =「2」參數,只需說textTitleValue.setText(editedResponse); – ObAt