Java 用于换行的Android Eclipse拆分
在我的应用程序android中,我插入了:Java 用于换行的Android Eclipse拆分,java,android,eclipse,Java,Android,Eclipse,在我的应用程序android中,我插入了: Log.i("myApp1", response.toString()); 这是Eclipse中LogCat for 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
Log.i("myApp1", response.toString());
这是Eclipse中LogCat for 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 />
在代码中使用
\n
,而不是HTML代码
String editedResponse = response.replaceAll("<br />", "\n");
Log.i("MyApp1", editedResponse);
String editedResponse=response.replaceAll(“
”,即“\n”);
Log.i(“MyApp1”,editedResponse);
如果要在文本视图中显示此字符串,请确保将android:line设置为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" />
好的,谢谢。现在,我有了这个输出
2014年3月23日
如何在布局android中使用此值设置textView?在textView中使用android:lines=“2”参数,在代码中只需说textTitleValue.setText(editedResponse);
<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" />