Welcome!

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

Reply
Developer
danielleCoder
Posts: 178
Registered: ‎04-16-2011
My Device: torch 9800
My Carrier: verizon
Accepted Solution

Custom Objects and Custom Lists

hi all,

 

In my apps on bb platform i got used to adding my custom objects in a list and implementing the display of these objects myself, using the objects properties as displayed text and images. It was then easy to retrieve these objects on selection, etc.

 

I dont see this in the list examples i have been looking at for pb, I see an option to set the label of the inserted list element and also set an icon.

 

How can i add my object to the list and display say the name property of this object?

 

Thanks in advance.

Please use plain text.
Super Contributor
pp
Posts: 278
Registered: ‎11-04-2010
My Device: 4.5 and above
My Carrier: none
Please use plain text.
Developer
danielleCoder
Posts: 178
Registered: ‎04-16-2011
My Device: torch 9800
My Carrier: verizon

Re: Custom Objects and Custom Lists

Hi PP.

 

these links are for smartphone, im am developing and posting on tablet sdk.

 

Regards

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Custom Objects and Custom Lists

Are you using the QNX List? Are you setting the dataProvider to an array of objects that will be listed in the list? The list looks for the "label" property in the array of objects. If you have a different layout to each item in the list, then you have to create your own renderer/skin. There are lots of examples on the forum.
Please use plain text.
Developer
danielleCoder
Posts: 178
Registered: ‎04-16-2011
My Device: torch 9800
My Carrier: verizon

Re: Custom Objects and Custom Lists

Hi John,

 

Yes I am using the qnx list. If I wanted to add the object in this list, how would i access this object in draw() for example in the cell renderer?

 

Another question which is very important to me is can the playbook lists have variable row heights? 

 

Regards

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Custom Objects and Custom Lists

The renderer is responsible to draw (and set values) for each item in the list. Search forum for "renderer" for list examples and/or see documentation on AlternatingCellRenderer. The "list" does not draw each item by a deverlopers override.

All items in the list are the same height. You can adjust that height on the list's rowHeight attribute. If you have a "list" that need different heights for each item, then you will need to create your own UIComponent subclass and add them to your own ScrollPane container. If you have *lots* of items, this may not scale well since the QNX List is good about only holding in memory the components that are displayed in the list and not the items outside the list's boundaries.
Please use plain text.
Developer
danielleCoder
Posts: 178
Registered: ‎04-16-2011
My Device: torch 9800
My Carrier: verizon

Re: Custom Objects and Custom Lists

John, thanks again for your help.

 

I have implemented my own list using container and scroll pane. This is going to be a chat window, i have done similar on the smartphone platform.

 

I am concerned when you say qnx is not so good at hanling large amount of items, is there any other approach which will be better for large items?

 

Otherwise, i am using the following to auto scrol my custom list, however, when i try to manually scroll it gets messed up and goes back to the start.

 

if(mainContainer.numChildren > 4)

{

if(scroll.scrollY == 0)

{

scroll.scrollY = 250;

}

else

{

scroll.scrollY = scroll.scrollY + 60;

 

}

}

 

Am i missing something for auto scroll to keep items in view?

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Custom Objects and Custom Lists

QNX can manage large number of items in their native controls, but since you are creating your own "list", you either need to limit the number of items in the list (~50-100 depending on UI complexity) or you need to manage object like the QNX list does (swaping items in and out to only those that are visible). Too many items in your own list you will start seeing it hard to scroll the list around.

The scroll container has to be the height of all the items that it contains and then the scroll pane function "update()" needs to be called so it can update it slider and etc. If (in your example) the height < 250, then calling scrollY to 250 will probably get some odd behavior.

Hope that helps.
Please use plain text.
Developer
danielleCoder
Posts: 178
Registered: ‎04-16-2011
My Device: torch 9800
My Carrier: verizon

Re: Custom Objects and Custom Lists

Thanks John,

 

I think im getting the hang of lists now, i will do some testing with custom implemented lists containing large amount of items and act accordingly.

 

Regards

Please use plain text.