Search code examples
listapache-flexselectionflex-spark

Flex/FlashBuilder :: Spark List / IconItemRenderer:: Disable Selection Highlight / No Selection / Remove Selection


I had trouble removing the selected and down state colors for a spark list using IconItemRender. If you are making a mobile app and using IconItemRender (instead of ItemRenderer) there is no autoDrawBackground property.

I figured I'd drop it in here after figuring it out thanks to this page: http://www.sajeevkumar.com/2012/01/08/flex-4-6-list-mobile-iconitemrenderer-background-image/


Solution

  • You can do the following to muck around with the down and selected colors. For more control over items in a list using IconItemRender look at the LabelItemRenderer class and the drawBackground function.

    override protected function drawBackground(unscaledWidth:Number, unscaledHeight:Number):void {
    
                var bgColor:uint = 0xffffff;
    
                graphics.clear();
    
                graphics.beginFill(bgColor,1);
                graphics.lineStyle();
                graphics.drawRect(0, 0, unscaledWidth, unscaledHeight);
                graphics.endFill();
    
                // Draw the separator for the item renderer
                super.drawBorder(unscaledWidth, unscaledHeight);
    
                opaqueBackground = bgColor;
            }