TextView的回车符不工作 [英] TextView carriage return not working

查看:108
本文介绍了TextView的回车符不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读从存储在具有存储用\\ n转义序列一些回车的SD卡的XML文件的字符串。如

 <字符串MyString的=1号线\\ nLine2>

但是,当我在显示仿真器中的文本中,\\ n被显示出来,而不是做一个换行符。我没有做什么不寻常的文字 - 只需用的SAXParser读它,然后将它添加到一个TextView。有没有设定我需要检查,以确保新行正确呈现?我需要不同的存储回车的xml文件?

我也尝试\\ r \\ n和不工作的。
当我调试,我可以看到一个额外的\\放置在现有的前\\
我看到,在我的SAX的startElement方法,行

 一个String = atts.getValue(MyString的);

分配线路1 \\ nLine2送的,所以问题是与SAXParser的。


解决方案

 &放大器; #xA;

工作得非常好了报价的TextView的中间。我想补充一点,在月蚀图形浏览器它放入一个多余的空格(如它是双倍行距)。当它不过编译和您在模拟器或设备运行它,你只需要回车。因此,相信MrGibbage,还能节省自己一些时间。

I am reading a string from an xml file stored on the sdcard that has some carriage returns stored with the "\n" escape sequence. Such as

<string mystring="Line1\nLine2">

But when I display the text in the emulator, the \n is showing up instead of making a newline. I am not doing anything unusual with the text--just reading it with a SAXParser and then adding it to a textview. Is there a setting I need to check to make sure newlines are rendered correctly? Do I need to store the carriage returns differently in the xml file?

I have also tried \r\n and that doesn't work either. When I debug, I can see that an extra \ is placed in front of the existing \ I see that in my SAX startElement method, the line

String s = atts.getValue("mystring");

assigns "Line1\nLine2" to s, so the problem is with the SAXParser.

解决方案

&#xA;

works very well in the middle of a quoted textview. I'd like to add that in Eclipses' graphic viewer it puts in an extra space (like it is double spaced). When it is compiled however and you run it on the emulator or a device, you only have the carriage return. So, trust MrGibbage and you'll save yourself some time.

这篇关于TextView的回车符不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆