简体   繁体   English

Android Eclipse Split for换行符

[英]Android Eclipse Split for newline

In my application android I've inserted : 在我的应用程序android中,我插入了:

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

This is the output of LogCat in Eclipse for response.toString: 这是Eclipse中LogCat对于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 />

How do I get this output in layout android? 如何在布局android中获得此输出? I need tried to split for < br /> without success... 我需要尝试拆分<BR />没有成功...

23/03/2014

Pics 1

09/03/2014

Pics 2

Instead of <br /> which is HTML code use \\n in your code. 在代码中使用\\n代替HTML代码的<br />

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

If you want to display this string in a TextView be sure you set the android:lines to 2 or greater. 如果要在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" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM