在Spark TextArea中显示HTML文本 [英] Display HTML text in the Spark TextArea

查看:153
本文介绍了在Spark TextArea中显示HTML文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



 <?xml version =1.0encoding =utf- 8\" >?; 
xmlns:s =library://ns.adobe.com/flex/spark
xmlns:mx =library://ns.adobe.com/flex/mx>
< fx:声明>
< mx:HTTPService id =httpRSSurl =http://www.petefreitag.com/rss/resultFormat =object/>
< / fx:声明>
< s:Panel id =readertitle =Blog Readerwidth =500>
< mx:DataGrid width =485id =entriesdataProvider ={httpRSS.lastResult.rss.channel.item}click ={body.htmlText = httpRSS.lastResult.rss.channel。项[entries.selectedIndex] .DESCRIPTION}>
< mx:columns>
< mx:DataGridColumn dataField =titleheaderText =TITLE/>
< mx:DataGridColumn dataField =pubDateheaderText =Date/>
< / mx:columns>
< / mx:DataGrid>
< mx:TextArea id =bodyeditable =falsewidth =485x =3y =142height =155/>
< / s:面板>
< / s:Application>

但是当Textarea更改为像下面那样引发Textrea时

 < s:TextArea id =bodyeditable =falsewidth =485x =3y =142height =155/> ; 

然后htmlText不支持Spark Textarea。因此产生错误。如何用火花文本区域属性显示HTML格式的文本。 如果您使用 RichEditableText 组件,则可以使用TextConverter类

  var myStr:String =我包含< b> html< / b>标记! 
myRichEditableText.textFlow = TextConverter.importToFlow(myStr,TextConverter.TEXT_FIELD_HTML_FORMAT);


The Below code is running well...

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
      xmlns:s="library://ns.adobe.com/flex/spark" 
      xmlns:mx="library://ns.adobe.com/flex/mx" >
 <fx:Declarations>
  <mx:HTTPService id="httpRSS" url="http://www.petefreitag.com/rss/" resultFormat="object" />
 </fx:Declarations>
  <s:Panel id="reader" title="Blog Reader" width="500">
  <mx:DataGrid width="485" id="entries" dataProvider="{httpRSS.lastResult.rss.channel.item}" click="{body.htmlText=httpRSS.lastResult.rss.channel.item[entries.selectedIndex].description}">
   <mx:columns>
    <mx:DataGridColumn dataField="title" headerText="TITLE"/>
    <mx:DataGridColumn dataField="pubDate" headerText="Date"/>    
   </mx:columns>
  </mx:DataGrid>
  <mx:TextArea id="body" editable="false" width="485" x="3" y="142" height="155"/>
 </s:Panel>
 <s:Button label="Load" x="10" y="329" click="{httpRSS.send()}"/>
 </s:Application>

But when Textarea is changed to spark Textrea like below

<s:TextArea id="body" editable="false" width="485" x="3" y="142" height="155"/>

Then htmlText doesn't support Spark Textarea. Hence produces error. How does one go about displaying HTML formatted text with spark Text Area Property.

解决方案

If you're using the RichEditableText component instead, you can do it this way using the TextConverter class

var myStr:String = "I contain <b>html</b> tags!";           
myRichEditableText.textFlow = TextConverter.importToFlow(myStr, TextConverter.TEXT_FIELD_HTML_FORMAT);

这篇关于在Spark TextArea中显示HTML文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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