如何将docx中的文本以其原始格式输入到Android Studio?

huangapple go评论82阅读模式
英文:

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)

如何将docx中的文本以其原始格式输入到Android Studio?

如何将docx中的文本以其原始格式输入到Android Studio?

答案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));

huangapple
  • 本文由 发表于 2020年9月15日 20:02:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/63901418.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定