Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6171153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:09:53+00:00 2026-05-23T23:09:53+00:00

This is my code for my implementation of a ListField. It creates a list;

  • 0

This is my code for my implementation of a ListField. It creates a list; however, it is empty even though I thought I add Friends from vectorFriends. I’m very new to developing blackberry apps, so I’m sure my error is pretty obvious. Can anyone tell me why my list is empty?

public class HomeScreen extends MainScreen implements FieldChangeListener, ListFieldCallback{
      private ListField listFriends;
      private Vector vectorFriends;
      private Friend _selectedPerson = null;

public HomeScreen(){
    vectorFriends = User.getMyUser().getFriends();

    this.add(new LabelField("Friends"));
    listFriends = new ListField(vectorFriends.size());
    listFriends.setCallback(this);
    this.add(listFriends)
}


//implemented ListFieldCallback methods
//draw current row
public void drawListRow(ListField list, Graphics g, int index, int y, int w) {
    Friend personToDraw = (Friend) this.get(list, index);
    int drawColor = Color.BLACK;
    g.setColor(drawColor);
    g.drawText(personToDraw.getFullName(), 0, y, 0, w);
}

// get the selected index from the correct Vector
public Object get(ListField list, int index) {
        return vectorFriends.elementAt(index);
}

public void insert(String toInsert, int index) {
       vectorFriends.insertElementAt(toInsert, index);
}


public int getPreferredWidth(ListField list) {
    return Display.getWidth();
}

public int indexOfList(ListField listField, String prefix, int start) {
    // Not a correct implementation - this is really just commented out
    return start;
}

 public int getPreferredWidth(ListField list) {
    return Display.getWidth();
}

public int indexOfList(ListField listField, String prefix, int start) {
    // Not a correct implementation - this is really just commented out
    return start;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:09:54+00:00Added an answer on May 23, 2026 at 11:09 pm

    Is vectorFriends empty perhaps?

    Also, your insert() method is adding String objects to the vector, while the drawListRow() method is casting to Friend. These are inconsistent.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code is from Prototype.js . I've looked at probably 20 different tutorials, and
This code always works, even in different browsers: function fooCheck() { alert(internalFoo()); // We
Why this code does not compile ( Parent is an interface)? List<? extends Parent>
This PHP code below fetches html from server A to server B. I did
I have this code: #import SQLiteDB.h @implementation SQLiteDB @synthesize db, dbPath, databaseKey; @end //--------------
Okay, I have this code in my ViewController.m : @implementation ViewController @synthesize generateButton =
This is a code that I got from the site here and I'd like
from this code #import AsyncImageView.h #import ImageCache.h #import ImageCacheObject.h static ImageCache *imageCache = nil;
Check out this code sample from Scott Guthrie's blog: http://weblogs.asp.net/blogs/scottgu/image_43366964.png Notice item is a
Update I've updated this question to include source code of a Java implementation, using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.