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

Posts: 81
Registered: ‎06-24-2009
My Device: Not Specified

Advice on writing my own ListField

[ Edited ]

I'm new to the platform. I'm hoping some of the gurus can help
me chose the ideal data structures for my UI.

I have a collection of objects I store sorted by date in a
SimpleSortingVector. Objects looks like this (simplified):

public class NewsUIItem extends VerticalFieldManager {

   LabelField headline;
   LabelField pubDate;
   LabelField publisher;
   LabelField author;
   BitmapField photo;

   public NewsUIItem(String headline, String pubDate) {
      this.headline = new LabelField(headline);
      this.pubDate = new LabelField(pubDate);





   protected void sublayout(int width, int height) {

      if(fieldCount() > 0) {
         Field headline = getField(0);


The NewsUIItems get added to a main VFM to create a list.


The question: What is the best way to keep the main VFM synced with the
vector of NewsUIItems?

Currently, I just set a dirty bit when adding/removing an item then clear
the main VFM and re-add all items from the vector. What is the cost of all
this? Will my app gets sluggish when the list grows to, say, 50 items?

The other solution is to keep another SimpleSortingVector on the main VFM
and wire it to add() and remove() methods that update the main VFM with
individual inserts and deletes.

Any others? I'm basically trying to write a more-flexible ListField with the
features I need.

Thanks for all the advice.

Message Edited by tkroll on 08-19-2009 10:05 AM