0 Replies Latest reply on Jul 20, 2011 3:18 AM by c0j0c

    Submenu in flex mobile application with List component (xml remote)

    c0j0c

      Hello!

       

      I created an example xml (main_en.xml):

       

      <?xml version="1.0" encoding="utf-8"?>
       <main>
       <id> <title>I</title> <picture>assets/imgs/1.jpg</picture>
       <id2> <subtitle>I</subtitle> <picture>assets/imgs/1.jpg</picture> <text><![CDATA[<I>I</I>]]></text> </id2>
       </id>
       <id> <title>II,III</title> <picture>assets/imgs/2.jpg</picture>
       <id2> <subtitle>II</subtitle> <picture>assets/imgs/1.jpg</picture> <text><![CDATA[<I>II</I>]]></text> </id2>
       <id2> <subtitle>III</subtitle> <picture>assets/imgs/2.jpg</picture> <text><![CDATA[<I>III</I>]]></text> </id2>
       </id>
      </main>

       

      Here my mxml:

       

      HomeView.mxml:

      <?xml version="1.0" encoding="utf-8"?>
      <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
            xmlns:s="library://ns.adobe.com/flex/spark" title="Test" creationComplete="view1_creationCompleteHandler(event)">
       <fx:Script>
       <![CDATA[
       import mx.events.FlexEvent;
       import spark.events.IndexChangeEvent;
       protected function view1_creationCompleteHandler(event:FlexEvent):void
       {
        TestXML.send();
       }
       
       protected function list1_changeHandler(event:IndexChangeEvent):void
       {
       navigator.pushView(SubMenu, event.target.selectedItem);
       }
       
       ]]>
       </fx:Script>
       <fx:Declarations>
            <s:HTTPService id="TestXML" url="assets/main_en.xml"/>
       </fx:Declarations>
       <s:List left="0" right="0" top="0" bottom="0" dataProvider="{TestXML.lastResult.main.id}" itemRenderer="IR.MyItemRenderer" labelField="title" change="list1_changeHandler(event)" ></s:List>
      </s:View>

       

      SubMenu.mxml:

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
            xmlns:s="library://ns.adobe.com/flex/spark" title="test" creationComplete="view1_creationCompleteHandler(event)">
       <fx:Script>
       <![CDATA[
       import mx.events.FlexEvent;
       
       import spark.events.IndexChangeEvent;
       
       protected function view1_creationCompleteHandler(event:FlexEvent):void
       {
        TestXMLMenu.send();
       }
       
       protected function list1_changeHandler(event:IndexChangeEvent):void
       {
       navigator.pushView(Details, event.target.selectedItem);
       }
       
       ]]>
       </fx:Script>
       <fx:Declarations>
            <s:HTTPService id="TestXMLMenu" url="assets/main_en.xml"/>
       </fx:Declarations>
       <s:List left="0" right="0" top="0" bottom="0" dataProvider="{TestXMLMenu.lastResult.id.id2}" itemRenderer="IR.MyItemRenderer" labelField="title" change="list1_changeHandler(event)" ></s:List>
      </s:View>

       

         How can I make a submenu like this?

      Untitled-111.png