简体   繁体   中英

How to Change the Style in TileList Selected Item using Flex?

My TileList Contain some text Boxes. i want to change the text color if it's selected. Please any one help me.. Thanks

Test this out, this should solve the issue. There's a custom renderer showing how to see if an item is selected.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
 xmlns:mx="http://www.adobe.com/2006/mxml">

 <mx:TileList id="tileList">
  <mx:dataProvider>
   <mx:ArrayCollection>
    <mx:Object text="one text"/>
    <mx:Object text="two text"/>
    <mx:Object text="three text"/>
   </mx:ArrayCollection>
  </mx:dataProvider>
  <mx:itemRenderer>
   <mx:Component>
    <mx:Canvas horizontalScrollPolicy="off" verticalScrollPolicy="off"
     updateComplete="updateTextColor()">
     <mx:Script>
      <![CDATA[
       import mx.controls.TileList;

       public var selectedColor:uint = 0xff0000;
       public var normalColor:uint = 0xaaaaaa;

       protected function updateTextColor():void
       {
        var selected:Boolean = TileList(this.owner).isItemSelected(this.data);
        var color:uint = selected ? selectedColor : normalColor;
        textArea.setStyle('color', color);
       }
      ]]>
     </mx:Script>
     <mx:TextArea id="textArea"
      text="{data.text}"/>
    </mx:Canvas>
   </mx:Component>
  </mx:itemRenderer>
 </mx:TileList>

</mx:Application>

Best, Lance

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM