Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Posts: 43
Registered: ‎11-17-2010
My Device: Not Specified

How do I get values of items on a list

Hey everyone!


I've been working on a simple app over the last few days and I have run into a problem. I was hoping to get some help with this issue. The part I am having problems with is getting information to display about a selected item on a list.The list I have going displays a list of projects. These projects all have id's and it's these id's I would like displayed in a seperate list. I figure I have to go about doing this using properties related to selectedIndex. For instance say I click the first item on the list that says "Project1"; how would I get that information to display on a seperate list? Each time the selectedIndex changes, the displayed information needs to change as well. This is what I was having trouble figuring out - how to display the changing content as different indexes are clicked.


Any help is appreciated....thank you!


p.s. The items on the list are from an RSS feed and are being fed into the list using an array

Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: How do I get values of items on a list

Assuming there is something unique about each item in the list (id, url, uid, etc.).


When you create the data provider, something like this:

var ar : Array = new Array();

// loop over feed items (feed_id and feed_label comes from your code)

ar.push( { id : feed_id, label : feed_label } );

// end loop
 this.mylist.dataProvider = new DataProvider( ar );


Create an Array with objects inside of them (denoted by {}).


On the event listener when the list is selected, you can easily determine which unique items was selected by:


var selection : String = this.mylist.selectedItem ? this.mylist.selectedItem.id : '';


 I typically check if the selectedItem from the list is not null (when something has not been selected) and then I get the value from the selected Object.


You can keep any type of information in the meta array that was given to the data provider.


In typical Adobe Flex/AIR, you can work with "bindings" to auto update state information, but not certain if this is avaiable in BB SDK (have not tried either).


Hope that helps.


Posts: 43
Registered: ‎11-17-2010
My Device: Not Specified

Re: How do I get values of items on a list

Thank you John, your help was much appreciated. I think this will help me solve the issue.