Search code examples
apache-flexflex4flexbuilderflex4.5

how to navigate in spark list control?


I'm building a mobile app, using spark list control. When user tap on a list item, i want it to navigate to that correspondence page

<s:List id="list" width="100%" height="100%" labelField=" label">
<s:dataProvider>
<s:ArrayList>
<fx:Object label="Page One" />
<fx:Object label="Page Two" />
<fx:Object label="Page Three" />
<fx:Object label="Page Four" />
</s:ArrayList>
</s:dataProvider>
</s:List>

 

  how do i code it so that when user tap on item label="Page One" it will navigate to PageOneView.mxml and if it tap on "Page Two" it will go to PageTwoView.mxml and so on.   thanks


Solution

  • The List should dispatch a change event. In that change event handler you can push the new view onto the view stack:

    if(list.selectedIndex == 0){
     navigator.pushView(viewOne);
    } else if (list.selectedIndex == 1){
     navigator.pushView(viewtwo);
    } else if 
    etc...