Search code examples
listboxmosync

How can I retrieve label text from ListBox in mosync?


I am using mosync 3.1. I have created a listbox and added labels as listbox items. I want to be able to retrieve the text or name of the label that is selected.


Solution

  • You should implement a "ItemSelectedListener" class and override the virual "itemSelected" method as this:

    virtual void itemSelected (ListBox *sender, Widget *selectedWidget, Widget *unselectedWidget)

    and then use this ListBox method:

    "void addItemSelectedListener (ItemSelectedListener *listener)"

    When an item selected in ListBox, the "itemSelectd" method has been called with "selected widget". Then you can get a text:

    ((Label*)selectedWidget)->getText()