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: 167
Registered: ‎12-17-2010
My Device: Bold 9000
My Carrier: Vodafone

Passing argument to CustomCellRenderer for List?

I want to do something specific in a custom CellRenderer, based on the data that is displayed, coming from a SQLite database table, like displaying a particular image or showing a number (somewhere on the row of the List).

What would be the approach to do that? Should I pass an argument from the main class to the custom CellRenderer? If so, how do I do that?


My PlayBook App: Checklists
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Passing argument to CustomCellRenderer for List?

Since you specify only a class, not instances, when you pass the custom renderer to setSkin(), you can't pass arguments to it... there is no "it" yet.

Instead, assuming the data required may differ from item to item, put it into the objects you pass in the array to the DataProvider. Then in your CellRenderer subclass, override the "set data" method to pull out the required information and do stuff with it. Assuming you want the usual behaviour as well, you'd generally need to do "super.data = value_passed_in" to make sure the parent class gets a chance to do its thing too.

There are examples that should be findable by searching this forum for something like "cellrenderer set data".

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!