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: 777
Registered: ‎07-21-2012
My Device: 9810
My Carrier: 0

Problem in preparing list field


i am facing problem in preparing list .there is a problem of i need to make custum list field.


public final class MyScreen extends MainScreen
     * Creates a new MyScreen object
    protected Vector listMembers ;;

    public MyScreen()
        // Set the displayed title of the screen       
        listMembers= new Vector();
        ListField l=new ListField();
        CustomList c=new CustomList(listMembers);
        //c.setCallback( listMembers);
add(c); } }



package mypackage;

import java.util.Vector;

import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.ListField;
import net.rim.device.api.ui.component.ListFieldCallback;

public class CustomList extends ListField implements ListFieldCallback{
Vector _v;

public CustomList(Vector listMembers) {
// TODO Auto-generated constructor stub
_v= listMembers;

public void drawListRow(ListField listField, Graphics graphics, int index,
int y, int width) {
graphics.drawText((String) _v.elementAt(index), 0, y,50);

public Object get(ListField listField, int index) {
// TODO Auto-generated method stub
return _v.elementAt(index);

public int getPreferredWidth(ListField listField) {
// TODO Auto-generated method stub
return 200;

public int indexOfList(ListField listField, String prefix, int start) {
// TODO Auto-generated method stub
return -1;



Please help me to solve this issue

Posts: 17,017
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Problem in preparing list field

i would suggest that you take a look at the list field samples that are available (for example by searching in the search box)
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Posts: 777
Registered: ‎07-21-2012
My Device: 9810
My Carrier: 0

Re: Problem in preparing list field

Thanks for applying..i got the solution./



Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem in preparing list field

Great, can you mark this as solved then - see Help link near the top for instructions if needed.