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: 49
Registered: ‎12-21-2010
My Device: 9000 Bold Device
My Carrier: software developer

ListCallBack issue

hello,

 

I am not getting any results from this code please check the code.

 

public class CMyFamilyFeature3 extends iFarmersScreen {
    int DISPLAY_WIDTH = Display.getWidth();
    int DISPLAY_HEIGHT = Display.getHeight();

    Vector vector1 = new Vector();
    Vector vector2 = new Vector();
    
    public CMyFamilyFeature3(){
    
        super(NO_VERTICAL_SCROLL|USE_ALL_HEIGHT);
        
        vector1.addElement("Life in A NutShell            04:08");
        vector1.addElement("Life - Tara Newby Story");
        vector1.addElement("Life - Mark Smith Story");
        
        vector2.addElement("This short video answers the basic questions with regard to the needs,specifications and the type of life insurance needed for a consumer.");
        vector2.addElement("Tara Newby describes her tragic experience with regard to the needs,specifications and the type of life insurance needed for a consumer.");
        vector2.addElement("In this short video Mark Smith Illustrated with regard to the needs,specifications and the type of life insurance needed for a consumer.");

         ListField listfield = new ListField();
           listfield.setBackground(BackgroundFactory.createSolidBackground(0x00FFFFFF));
            listfield.setRowHeight(80);
            myListFieldCallBack callback = new myListFieldCallBack();
            listfield.setCallback(callback);
         //   listfield.setChangeListener(buttonSet);
            listfield.setSize(vector1.size());
          add(listfield);
    }
    
}

ListFieldCallback class

 

public class myListFieldCallBack implements ListFieldCallback{
    
    int DISPLAY_WIDTH = Display.getWidth();
    int DISPLAY_HEIGHT = Display.getHeight();
    private static final int LEFTMOST = 0;
    Vector vector1 = new Vector();
    Vector vector2 = new Vector();
    
    public void drawListRow(ListField listField, Graphics graphics, int index,
            int y, int width) {
        int xpos = LEFTMOST;
        int ypos = y+30;
        String text = (String)vector1 .elementAt(index);
        String text1 = (String)vector2.elementAt(index);
        Font ourBoldFont = ourFont.derive(Font.BOLD);
        graphics.drawText((char) text.indexOf(index), 110, y, 0, width);
        graphics.drawText(text1, xpos+15+90, ypos);
        graphics.drawRect(0, ypos-30, width, 0);
}
public Object get(ListField listField, int index) {
    //return vector1.elementAt(index);
    return listField;
}

public int getPreferredWidth(ListField listField) {
    return DISPLAY_WIDTH;
}

public int indexOfList(ListField listField, String prefix, int start) {
    return -1;
}
}

is this code is right or any thinking missing.

please check this code and give me solution for this..

 

thanks

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

Re: ListCallBack issue

in your draw callback you create new vectors (1&2) which are empty. i would also suggest that you use only a single vector and create a bean class for your attributes.
----------------------------------------------------------
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
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: ListCallBack issue

Are you using two ids and repeating your problems?  That's is not playing fair for a number of reasons.  Please just use one id and ask questions once.

http://supportforums.blackberry.com/t5/Java-Development/custom-ListField-issue/m-p/722519