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

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

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

Re: ListField Issue

Sorry I am very busy - you will notice I have not been lurking here much in the last few days.


"I have posted code and wireframe...now can u pls help? "


Is that what I suggested you do?  I thought there were a few other things from my last post, like developing your Field step at time, and describing exactly what you see and what you expect to see.  For example, in this case, we have no idea which part of the wireframe the code is supposed to create nor how far off it actually is, or how it is failing.  You can help us more to help you....


And while I could create code for you, that doesn't really help you.  To make you a better BB programmer, the best thing is for you to code it yourself. 


I have, on this Thread, already provided some useful links (http://supportforums.blackberry.com/t5/Java-Development/ListField-Issue/m-p/1776025#M202510) and a process I would recommend for you to progress this for yourself.  You can do this even when I am busy and don't have time to help, so this seems like the best way forward, and you learn how to program too.


Anyway, looking at your code, there are some issues I think.


1) The first thing is to note that if you want each row to be separately focusable, it will have to be a separate Field.  There are variations possible but from someone new to BB the variations are too difficult.  So whatever you want to be separately focusable should be a separate Field.


2) In your code you have this:

"int height;
height = str.length/9;
if(height%9 > 0)
height = height * 20;"

This looks odd to me. Since you are trying to output a line for each element in the str array, it would seem more reasonable t have a line per element.  Assuming the font you have used contains 20 pixels in height (see Font class), then when you lay this out, the code to determine the height is just

str.len * 20


Alternatively and better perhaps

height = str.length * (this.getFont().getHeight());


3) We have already been over this code in a separate Thread:

"for(int i=0;i<str.length;i++)

You are painting all the lines at position 5 on the x axis and 30 on the y.  I am sure you really want something like this:


int currY = 5;

for(int i=0;i<str.length;i++)

currY += graphics.getFont().getHeight();

Hope fully these suggestions will move you along.


Please review the code I have suggested above and make sure you understand it.  I'm not guaranteeing the code, so you will probably need to check it yourself anyway.  Please understand if there is a bug or typo in there and fix it yourself.


And please in future, post problems with a full description of the problem, which includes what you want and what you actually see. And make sure you work the problem, try variations, simplify the code until it starts working and so on.  That is how you will learn.  You will not learn by simply posting your spec, and your current code and asking us to write the correct code for you. Unless you are willing to pay us to do this of course.  Smiley Happy