2013-07-10 2 views
0

문제가 있습니다.항공 모바일 앱 목록 Item 렌더러 scolling 문제

내가 1 스크롤에 다음 표시 항목에 중복되는 기록에서 목록 데이터를 스크롤하기 시작할 때 화면 에에 표시 할 수있는 다음 데이터 행의 큰 수를 반환하는 경우

실시 예 10

데이터 레코드 는

표시

시작 scrolll 5는 1 개 또는 2 데이터 O 등을 표시 할 수있다 (1 개) 데이터 6 diplaying되고 n

목록에 표시된 레코드 수가 10 개이고 정보가 올바르지 않습니다.

여기서,

 protected function display_gas_pricesResult_resultHandler(event:ResultEvent):void 
     { 
     currentState='start_here'; 
     this.list.dataProvider=null; 
     this.list.dataGroup.invalidateDisplayList(); 
     label_waterway.text=this.BoaterObject.waterway; 
     var _itemRenderer:IFactory=this.list.itemRenderer; 
     this.list.itemRenderer=null; 
     this.list.itemRenderer=_itemRenderer; 
     this.list.dataProvider=TypeUtility.convertToCollection(display_gas_pricesR esult.lastResult); 
     this.list.validateDisplayList(); 
     } 



<s:List id="list" 
    width="100%" 
    height="100%" 
    change="list_changeHandler(event)" 
    contentBackgroundAlpha="0" 
    pageScrollingEnabled="true" 
    borderVisible="true" 
    scrollSnappingMode="leadingEdge" 
    itemRenderer="renderers.ir_gas_prices"> 
<s:layout> 
    <s:VerticalLayout/> 
</s:layout> 
</s:List> 

<?xml version="1.0" encoding="utf-8"?> 
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
     xmlns:s="library://ns.adobe.com/flex/spark" 
     width="100%" color="#000000" 
     creationComplete="itemrenderer1_creationCompleteHandler(event)" 
     autoDrawBackground="false" contentBackgroundAlpha="0"> 
     <s:layout> 
     <s:HorizontalLayout gap="1" 
     paddingBottom="5" 
     paddingLeft="5" 
     paddingRight="5" 
     paddingTop="5" 
     verticalAlign="middle"/> 
     </s:layout> 
     <fx:Script> 
     <![CDATA[ 
     import mx.events.FlexEvent; 

     protected function itemrenderer1_creationCompleteHandler(event:FlexEvent):void 
     { 
     if (data.gas_price_id == '0') 
     { 
     currentState='no_prices'; 

     } 
     else 
     { 
     currentState='show_price'; 
     label_name.text=data.name; 
     label_status.text=data.status; 
     label_gas.text=data.gas_price; 
     label_diesel.text=data.diesel_price; 
     label_date.text=data.date; 
     label_boatname.text=data.boat_name; 
     } 
     } 
     ]]> 
     </fx:Script> 
     <s:states> 
     <s:State name="show_price"/> 
     <s:State name="no_prices"/> 
     </s:states> 
     <s:BorderContainer width.show_price="100%" height.show_price="100%" cornerRadius.show_price="10" 
      dropShadowVisible.show_price="true"> 
     <s:layout.show_price> 
     <s:HorizontalLayout paddingBottom="5" paddingLeft="5" paddingRight="5" paddingTop="5"/> 
     </s:layout.show_price> 
     <s:VGroup width="15%" 
      horizontalAlign="center"> 
     <s:Image width="56" 
     height="46" 
     source="@Embed('assets/basic1-088.png')"/> 
     <s:Label id="label_status" includeIn="show_price" width="100%" color="#662100" fontSize="18" 
     text="Label" textAlign="center"/> 
     </s:VGroup> 
     <s:VGroup width="100%" 
      gap="1"> 
     <s:HGroup width="100%"> 
     <s:Label id="label_name" includeIn="show_price" width="100%" color="#662100" 
     fontSize="20" fontWeight="bold" text="Label"/> 
     <s:Label includeIn="no_prices" 
     fontSize="16" 
     text="Sorry no one has posted any fuel prices yet.&#xd;Be the first to post fuel prices on this water way.&#xd;Click the add button "/> 
     </s:HGroup> 
     <s:HGroup includeIn="show_price" 
      width="100%" 
      horizontalAlign="left" 
      paddingLeft="20"> 
     <s:VGroup gap="1" 
      horizontalAlign="center" 
      verticalAlign="top"> 
     <s:Label fontSize="18" 
     fontWeight="bold" 
     text="Gas"/> 
     <s:HGroup width="100%"> 
     <s:Label fontFamily="_typewriter" 
     fontSize="24" 
     fontWeight="bold" 
     text="$"/> 
     <s:Label id="label_gas" 
     color="#FF0303" 
     fontFamily="_typewriter" 
     fontSize="24" 
     fontWeight="bold" 
     text="Label"/> 
     </s:HGroup> 
     </s:VGroup> 


     <s:VGroup gap="1" 
      horizontalAlign="center" 
      verticalAlign="top"> 
     <s:Label fontSize="18" 
     fontWeight="bold" 
     text="Diesel"/> 
     <s:HGroup width="100%"> 
     <s:Label fontFamily="_typewriter" 
     fontSize="24" 
     fontWeight="bold" 
     text="$"/> 
     <s:Label id="label_diesel" 
     color="#00CA26" 
     fontFamily="_typewriter" 
     fontSize="24" 
     fontWeight="bold" 
     text="Label"/> 
     </s:HGroup> 
     </s:VGroup> 
     <s:Spacer width="20%" 
      height="10"/> 
     <s:VGroup width="50%" 
      gap="1" 
      horizontalAlign="right"> 
     <s:Label id="label_date" 
     width="100%" 
     fontSize="16" 
     text="Label" 
     textAlign="right"/> 
     <s:HGroup width="100%" 
      horizontalAlign="right"> 
     <s:Label fontSize="16" 
     fontWeight="bold" 
     text="By:"/> 
     <s:Label id="label_boatname" 
     fontSize="16" 
     text="Label"/> 
     </s:HGroup> 
     </s:VGroup> 
     </s:HGroup> 
     </s:VGroup> 
     </s:BorderContainer> 
     </s:ItemRenderer> 

답변

0

ItemRenderers가 perfomance의 연고로 재사용 코드 인 경우 (기본값) 진정한 List.useVirtualLayout ==. 다시 사용할 수있게하려면 데이터가 변경 될 때마다 모든 레이블 등이 기본값으로 다시 설정되어야합니다. 는이를 달성하기 위해, 새로운 데이터가 렌더러로 설정 될 때마다 그 호출되면,

set data(value:Object):void 

함수를 재정의하는 것은 매우 일반적입니다.

렌더러가 생성 될 때 "creationComplete"이벤트가 AFAIK를 한 번만 실행합니다. 즉, 디스플레이가 올바르게 업데이트되지 않습니다.