-1

Is there a list box in Flex 4.6?

If yes,can sm1 tel me how to implement a list box in Flex code

Thanks

ketan
  • 19,129
  • 42
  • 60
  • 98
Swetha
  • 11
  • 5

1 Answers1

2

Flex has a Spark List control, using an IList (ArrayList or ArrayCollection) as the data provider.

list

Declarative approach:

Using MXML, this is implemented as <s:List>, as in:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark">

    <s:List>
        <s:dataProvider>
            <s:ArrayList>
                <fx:String>Item 1</fx:String>
                <fx:String>Item 2</fx:String>
                <fx:String>Item 3</fx:String>
            </s:ArrayList>
        </s:dataProvider>
    </s:List>

</s:Application>


Programmatic approach:

From code, a list is instantiated and added to the display list such as:

import mx.collections.ArrayList;
import spark.components.List;

var list:List = new List();
list.dataProvider = new ArrayList([ "Item 1", "Item 2", "Item 3" ]);
addElement(list);


References:

Jason Sturges
  • 15,855
  • 14
  • 59
  • 80
  • @Swetha If you want a static factory class `static function addListBox():List { return new List(); }`. Then, add the `VisualElement` using `addElement()`. – Jason Sturges Nov 03 '12 at 19:01
  • I need a method for listbox like private static function addListBox(parentGrp:BorderContainer, listBoxClass:XdListBox_XdBehavior_Select,tagAtts:Object):List{ } – Swetha Nov 05 '12 at 06:38