Flex 4 spark List width resize issue

I've got a spark List with an item renderer. When I click on an element, the renderer becomes larger and when I click again, it becomes small again. The problem is that list doesn't resize with the content. I've tried to dispatch an event from the renderer passing its content size and resize list in this way:

private function refreshList(event:ResultEvent):void
      {
        var size:Number = (event.result as Number) + 6;

        if (size >= mylist.width)
        {
          consultingNumber++;
          mylist.width = size;
        }
        else
        {
          consultingNumber--;
          if (consultingNumber == 0)
            mylist.width = size;
        }
        mylist.invalidateDisplayList();

      }

consultingNumber is the number of 'opened' renderer. It works quite well, but when all renderer is 'closed' an horizontal scrollbar appear. Tracing list's width it result correct but the scrollbar is there even if I set horizontalScrollPolicy to off.


Try calling myList.invalidateSize() instead of myList.invalidateDisplayList();

Here is some more information about the flex component lifecycle which should get you on the right track:

http://weblog.mrinalwadhwa.com/2009/06/21/flex-4-component-lifecycle/

http://www.slideshare.net/rjowen/adobe-flex-component-lifecycle-presentation

Cheers

链接地址: http://www.djcxy.com/p/34616.html

上一篇: 火花列表控件显示dataProvider更新中的数据不完整

下一篇: Flex 4火花列表宽度调整大小问题