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

Java Development

Reply
Contributor
Posts: 33
Registered: ‎05-14-2010
My Device: Blackberrry Pearl 8320
My Carrier: Unbranded

Re: Understanding ListField - Do I suck or does this class suck?

[ Edited ]

Ok guys Ive learned a lot of things from this thread. (I like to learn stuff)

 

Now my final question is. If ListFieldCallback does not get implemented,... what happens exactly?

 

EDIT: And also do I have to make a custom Manager. Like can I just create a Field on drawListRow, and then lay it out (hmmm somehow, Im not sure how)

Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: Understanding ListField - Do I suck or does this class suck?

A ListField is basically useless without a ListFieldCallback. From the API docs:

A ListField must register a class that implements the ListFieldCallback interface using the setCallback method before the class can be used.

If you don't have one, when a ListField needs to display a row, it either does nothing or throws an exception (I don't know which--never tried it.)

 

For drawListRow, you can use any kind of Field to organize the lay-out. It doesn't have to be a Manager, although that is usually what you'd want to use if the row layout is best done by arranging subordinate fields (labels, bitmaps, rich text, etc.). Of course, you don't need to use any kind of Field at all; you can keep your own data structures and do the layout computations yourself. The only reason to use a Field (more specifically, a Manager), is to take advantage of the functionality already there in the RIM APIs.

 

Your ListFieldCallback can be implemented anywhere: you can subclass ListField and implement it there (that's what ObjectListField does); you can implement it in the containing Manager/Screen (which might already have all the needed data); or it can be a stand-alone class (which might make it easier to plug in different "looks" for your list). The choice is a style issue, I think, and no method is best.




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Contributor
Posts: 33
Registered: ‎05-14-2010
My Device: Blackberrry Pearl 8320
My Carrier: Unbranded

Re: Understanding ListField - Do I suck or does this class suck?

Thanks a lot man.

I am understanding more and more about this.


The only weird thing is that my code works without a ListFieldCallback.

 

Anyway now Im trying to implement ListFieldCallback, but for some reason drawListRow, doesnt get called. (I setCallback(this); in my constructor)