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
Developer
Posts: 53
Registered: ‎10-02-2009
My Device: BlackBerry Tour 9630
My Carrier: Verizon

ListField with Separators

I'm trying to figure out how I can create a LabelField with line separators?  Does anyone know how to do this?  Should I just put a bunch of LabelFields with Line Separators in a Vertical Layout?

 

Thanks!

 

-J

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: ListField with Separators

ListField has a callback to draw the row - just draw a line at the bottom of each row cell.

 

Developer
Posts: 53
Registered: ‎10-02-2009
My Device: BlackBerry Tour 9630
My Carrier: Verizon

Re: ListField with Separators

Thanks for the prompt reply.  I tried that, but for someone reason it doesn't draw.

 

 

    public void drawListRow(ListField list, Graphics g, int index, int y, int w) {
        g.drawText("Line One", 0, y, 0, w);
        g.drawLine(0, 0, Graphics.getScreenWidth(), 0);
    }

 

 

I'm probably doing it wrong.  It draws the line across, but it only does it on the top of the first row.  It doesn't repeat it.  If I set the size of the ListField to 3, it still only draws the line at the top of the first row.

 

 

        ListField profileList = new ListField();
        profileList.setEmptyString("No Active Profiles...", DrawStyle.LEFT);
        profileList.setSize(3);
 profileList.setBorder(BorderFactory.createSimpleBorder(new XYEdges(1,0,1,0))); profileList.setCallback(new TestListCallback());

 

Please help!  Thanks again!

 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: ListField with Separators

From the javadocs:

 

Invoked when a particular row requires painting.

The graphics context passed to this method represents the entire list, not just the row for repainting. Accordingly, the y parameter indicates how far down in the list the repaint should occur.

Developer
Posts: 53
Registered: ‎10-02-2009
My Device: BlackBerry Tour 9630
My Carrier: Verizon

Re: ListField with Separators

Ok.  That makes sense.  I'll give it a try!  Thanks!

Developer
Developer
Posts: 34
Registered: ‎11-02-2009
My Device: Not Specified

Re: ListField with Separators

[ Edited ]

hi jsdyer, i'm looking for this issue too, so plz post ur solution here if you can solve it. Thanks!

 

i have tried and it worked! ... but it draw line at the top of the first line too, how can i remove it ?

 

 

 

Developer
Posts: 696
Registered: ‎12-02-2008
My Device: Not Specified

Re: ListField with Separators

Hi,

 

First draw your text then draw the line,it should solve the issue,also remeber that value of y should be 5-6 pixel more then the height of the text in first line,so that line gets drawn from the bottom of the text.

Regards,
Rajat Gupta.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
Developer
Posts: 696
Registered: ‎12-02-2008
My Device: Not Specified

Re: ListField with Separators

Hi,

 

 

First draw your text then draw the line,it should solve the issue,also remeber that value of y should be 5-6 pixel more then the height of the text in first line,so that line gets drawn from the bottom of the text.

Regards,
Rajat Gupta.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
Developer
Posts: 17,011
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: ListField with Separators

instead of y as a parameter use (getRowHeight() + y -1), this will draw the line to the bottom.

----------------------------------------------------------
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