英文:
How to input text from docx to Android Studio in its original form?
问题
我正在制作一个简单的Android应用(使用Android Studio),应用的一部分需要显示我在docx文件中编写的文本。当我将文本粘贴到textView中时,所有的换行都消失了,只剩下了好像在记事本中输入的文本。
如何导入文本并保持其原始格式?(如果只是少量文本就不会有问题,但文本内容很多,手动更正需要很多时间,而且效率不高)
图片链接:
如何在docx中显示(示例文本):图片1
如何在Android Studio中显示:图片2
英文:
I am making a simple android app(in Android Studio) and one of the parts of the app requires showing text that I wrote in docx. When I paste my text in a textView, all my new lines are gone, I'm left with text as If I was typing it in a notepad.
How can I import text and maintain it's original form? (It wouldn't be a problem if it was one smaller text, but there's a lot of it and manualy correcting it would take a lot of time,and it's not really efficient)
答案1
得分: 0
使用Word对我来说似乎不是正确的方法,但是TextView支持HTML,这对于你的示例应该足够:
textView.setText(Html.fromHtml("
Lorem ..<br\>
Lorem ...<br\>
<ol>
<li>Lorem ...</li>
<li>LOREM ...</li>
</ol>", Html.FROM_HTML_MODE_COMPACT));
英文:
Using Word seems like the wrong approach to me, but the textview supports html, which should be suffient for your example:
textView.setText(Html.fromHtml("
Lorem ..<br\>
Lorem ...<br\>
<ol>
<li>Lorem ...</li>
<li>LOREM ...</li>
</ol>", Html.FROM_HTML_MODE_COMPACT));
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论