我有庞大的多段TextView。 TextView的内容从Strings.xml加载。
我想显示多个段落。当我在strings.xml中使用<P></P>
标记时,它没有被反映出来,TextView将所有脚本显示为一个单独的段落。
有没有办法将文本分成几段?
strings.xml的内容:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, sirukathaikal!</string>
<string name="app_name">Eelathu Sirukathaikal</string>
<string name="main_title">®ÆòÐî º¢Ú¸¨¾¸û</string>
<string name="continue_label">njhlu;f...</string>
<string name="about_label">nrayp cjtp</string>
<string name="about_content">,e;j md;nuhapl; nrayp %yk; ,yq;ifiar; Nru;e;j kA+Nurd; vOjpa %d;W rpWfijfis ntspapLfpd;Nwhk;. njhlu;f vd;w nghj;jhidr; nrhLf;fp fijfis thrpf;fTk;. </string>
<string-array name="story_list">
<item>Story 1</item>
<item>Story 2</item>
<item>Story 3</item>
</string-array>
<string name="story_body">
<p>þ¼õ: ¦¸¡ØõÒ</p>
<p>§¿Ãõ: ¸¡¨Ä 7.30</p>
<p>¬ñÎ: 2019</p>
<p>Å¢ó¾¢Â¡ ¾ÉÐ ¨¸Â¢ø þÕìÌõ ¨À¨Â þÚì¸ «¨½ò¾ÀÊ ¿¼óÐ ¦¸¡ñÊÕó¾¡û. Å£¾¢ ¦ÅȢ¡Êì ¸¢¼ó¾Ð. ¾ÉÐ ¿¨¼¨Â ¦ÁøÄ ¦ÁøÄ §Å¸ôÀÎò¾¢ì¦¸¡ñ§¼ ţΠ§¿¡ì¸¢ ¿¼ì¸ò ¦¾¡¼í¸¢É¡û.
¨¸Â¢ø þÕìÌõ «ó¾ô ¨À¢ý ¦ÀÚÁ¾¢ «ÅÙìÌò¾¡ý ¦¾Ã¢Ôõ. Å£ðÊø «¨ÉÅÕõ þó¾ô ¨À¢ø þÕôÀ¨¾ò¾¡ý ±¾¢÷À¡÷òÐ ¸¡ò¾¢Õ츢ýÈ¡÷¸û. ¡÷ ¸ñ½¢Öõ ÀðÎÅ¢¼Á¡ø ¦ºýÚÅ¢¼§ÅñÎõ ±ýÀ¾¢ø ÌȢ¡¸ þÕó¾¡û. ÀòÐ ¬ñθÙìÌ Ó¾ø þó¾ þ¼ò¾¢ø þó§¿Ãò¾¢ø ºÉõ ÍõÁ¡ §ƒ.. §ƒ… ±ýÚ ¿¼Á¡Îõ. þô§À¡ ±øÄ¡õ ¾¨Ä¸£ú.
º¢ó¾¨É¸Ç¢ø ÍÆýÈÅ¡Ú ¿¼óЦ¸¡ñÊÕó¾¡û Å¢ó¾¢Â¡. «ó¾ ºó¾¢¨Âì ¸¼óÐÅ¢ð¼¡ø ¾ý ţ𨼠«Îò¾ 5 ¿¢Á¢¼ò¾¢ø «¨¼óÐÅ¢¼Ä¡õ ±ýÈ ¿õÀ¢ì¨¸Â¢ø ¿¨¼Â¢ý Å¢¨Ã¨Åì ÜðÊÂÅ¡Ú ºó¾¢¨Â §¿ì¸¢ ¿¼ì¸ò ¦¾¡¼í¸¢É¡û.
¾¢Ë÷ ±ýÚ ±í¸¢Õ󧾡 ´Õ «ÊÀðÎ ¦¿Ç¢ó¾ ¼¡¼¡ þýʸ¡ ¸¡Ã¢ø ¿¡ý¨¸óÐ þ¨Ç»÷¸û. ¸¡÷ ºò¨¾ò¨¾ Å¢¼ «Å÷¸û §À¡ð¼ ºò¾§Á «¾¢¸Á¡¸ þÕó¾Ð. ´Õò¾ý ¸¡Ð Ìò¾¢Â¢Õó¾¡ý ÁüÈÅý ¸ñþ¨Á¢ø ²§¾¡ Ìò¾¢Â¢Õó¾¡ý.
“§¼ö «í¸ À¡Õ¼¡! ²ö……….. ±ýÉ ¨¸Â¢Ä?” ¸¡Ã¢ø þÕó¾ ´Õò¾ý °¨Ç¢ð¼¡ý.</p>
<p>ÌÉ¢ó¾ ¾¨Ä ¿¢Á¢Ã¡Áø Å¢ó¾¢Â¡ «ó¾ þ¼ò¾¢ø þÕóÐ ¦ÁøÄ ¿¸Ãò ¦¾¡¼í¸¢É¡ø. «Å¨Ç º¢È¢Ð ¸¼óÐ ¿¢ýÚ þÕó¾ ¸¡÷ þô§À¡Ð, ¸¢Ã£î ±ýÈ ºò¾§¾¡Î «Åû ÓýÉ¡ø ÅóÐ ¿¢ýÈÐ. ¸¡Ã¢ø þÕóÐ ¿¡ýÚ þ¨Ç»÷¸Ùõ ¾¼ ¾¼¦ÅÉ þÈí¸¢É÷. ´ù¦Å¡Õò¾ý ¸ñ½¢Öõ ¦ÅÈ¢ ¾¡ñ¼ÅÁ¡ÊÂÐ.
´Õ «Ê ÓýÛìÌ ±ÎòÐ ¨Åò¾ ´Õò¾ý Å¢ó¾¢Â¡ ¨¸Â¢ø þÕó¾ ¨À¨Â ÀÈ¢ò¾¡ý. ¨À¨Â ¾¢ÈóÐ ¯û§Ç À¡÷ò¾Åý, ÁüÈÅ÷¸¨Çô À¡÷òÐ Òýɨ¸Ô¼ý ¾¨Ä¡ðÊÉ¡ý.
“§¼ö… ¾¡¼¡!!!” Å¢ó¾¢Â¡ ÀÈ¢ò¾Åý ¸ýÉò¾¢ø º¼¡÷ ±ýÚ ´Õ «¨È Å¢ð¼¡û. «¨Èó¾ ºò¾õ µöžüÌû ´Õ ºò¾õ ‘ÎÁ£ø’. Å¢ó¾¢Â¡Å¢ý ¯¼ø ¸£§Æ ºÃ¢Â «Åû ¯¼Ä¢ø þÕóÐ þÃò¾ý ÌÒ ÌÒ ±É ¦ÅÇ¢§ÂÈò ¦¾¡¼í¸¢ÂÐ.
Å¢ó¾¢Â¡Å¢üÌ Í ¿¢¨É× ¦ÁøÄ ¦ÁøÄ «¸Äò ¦¾¡¼í¸¢ÂÐ. ¸ñ¸û þÕð¼ò ¦¾¡¼í¸¢ÂÐ. ¸¨¼º¢Â¡¸ ¸ñ ã¼ ÓýÉ÷, ¾ý ¨À¢ø þÕó¾ À¡ñ Ðñ¨¼ «ó¾ì ¸ÂÅ÷¸û Å¢Äí̸¨Çô §À¡Ä À¢öòÐ ¯ñÀ¨¾ì ¸ñ¼¡û. ¦ÁøÄ ¦ÁøÄ «Åû ¯Ä¸õ þÕÇò ¦¾¡¼í¸¢ÂÐ.
À¢.Ì: Ôò¾õ Å¢¨ÃÅ¢ø µÂ¡Å¢ð¼¡ø ´Õ¿¡û ŠÃ£ Äí¸¡Å¢ø þÐ ¿¼ì¸ô §À¡ÅÐ ¿¢îºÂÁ</p>
</string>
</resources>
BodyStory1.java:
package com.mayuonline.com.esiru;
import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.TextView;
public class BodyStory1 extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.story_body);
Typeface tf = Typeface.createFromAsset(getAssets(),"fonts/kaviri.TTF");
TextView tvBody = (TextView) findViewById(R.id.story_body);
tvBody.setTypeface(tf);
}
}
添加setText()后storyBody1.java: 包com.mayuonline.com.esiru;
import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.text.Html;
import android.widget.TextView;
public class BodyStory1 extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.story_body);
setText(Html.fromHtml(getString(R.string.story_body)));
Typeface tf = Typeface.createFromAsset(getAssets(),"fonts/kaviri.TTF");
TextView tvBody = (TextView) findViewById(R.id.story_body);
tvBody.setTypeface(tf);
}
}
答案 0 :(得分:2)
设置TextView
的文字时,请尝试使用
Typeface tf = Typeface.createFromAsset(getAssets(),"fonts/kaviri.TTF");
TextView tvBody = (TextView) findViewById(R.id.story_body);
tvBody.setTypeface(tf);
tvBody.setText(Html.fromHtml(getString(R.string.story_body))));