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


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.


Reply
Developer
Posts: 777
Registered: ‎07-21-2012
My Device: 9810
My Carrier: 0
Accepted Solution

How to implement custom llistfield having alternate color in row

Hello sir

can you please tell me how to implement custom listfield having alternate color in alternate row.actually this type of list field used to many time so i want to make custime listfield

Thanks is advance.h.jpg

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

Re: How to implement custom llistfield having alternate color in row

in http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/ui/component/ListFieldCallback... you get the index. just check if it is %2=0 and paint a background.
----------------------------------------------------------
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: 777
Registered: ‎07-21-2012
My Device: 9810
My Carrier: 0

Re: How to implement custom llistfield having alternate color in row

any other example..Smiley Sad

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

Re: How to implement custom llistfield having alternate color in row

check http://supportforums.blackberry.com/t5/Java-Development/Create-a-colour-ListField/ta-p/442955
----------------------------------------------------------
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: 777
Registered: ‎07-21-2012
My Device: 9810
My Carrier: 0

Re: How to implement custom llistfield having alternate color in row

How to make column  in list as in my in listfield..?

Developer
Posts: 777
Registered: ‎07-21-2012
My Device: 9810
My Carrier: 0

Re: How to implement custom llistfield having alternate color in row

Thanks sir how to make coloumn 

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

Re: How to implement custom llistfield having alternate color in row

You draw rows. If you want columns you draw stuff at a certain point in your row, like x = 50, using drawText("yourtext", 50, y).
see
http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/ui/Graphics.html#drawText(java...

a listfield is row based, you cannot focus columns. If you need that, you have to use another component.
----------------------------------------------------------
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: 777
Registered: ‎07-21-2012
My Device: 9810
My Carrier: 0

Re: How to implement custom llistfield having alternate color in row

Thanks sir ...

 

more suggestion to clear this thing..i 

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

Re: How to implement custom llistfield having alternate color in row

please take the sample and modify it.
if you have any special issues you can ask here.
----------------------------------------------------------
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
Highlighted
Developer
Posts: 777
Registered: ‎07-21-2012
My Device: 9810
My Carrier: 0

Re: How to implement custom llistfield having alternate color in row

hello 

 

i am using the download code (customcolorList.zip).here Here i change some thing in paint method .actually i need different colour in each colum also as i  display in my image (previous post).But when focus is coming in row it  paint the whole column (didn't display  2 column ) . i only change in paint method.

 

 

public void paint(Graphics graphics) {
// Get the current clipping region as it will be the only part that
// requires repainting
XYRect redrawRect = graphics.getClippingRect();
if (redrawRect.y < 0) {
throw new IllegalStateException("Clipping rectangle is wrong.");
}

// Determine the start location of the clipping region and end.
int rowHeight = getRowHeight();

int curSelected;

// If the ListeField has focus determine the selected row.
if (hasFocus) {
curSelected = getSelectedIndex();
} else {
curSelected = -1;
}

int startLine = redrawRect.y / rowHeight;
int endLine = (redrawRect.y + redrawRect.height - 1) / rowHeight;
endLine = Math.min(endLine, getSize() - 1);
int y = startLine * rowHeight;

// Setup the data used for drawing.
int[] yInds = new int[] { y, y, y + rowHeight, y + rowHeight };
int[] xInds = new int[] { 0, getPreferredWidth(), getPreferredWidth(),
0 };

// Get the ListFieldCallback.
// This sample assumes that the object returned by the get
// method of the callback is a String or has a toString method.
// If this is not the case you will need to add the required logic
// for your implementation.
ListFieldCallback callBack = this.getCallback();

// Draw each row
for (; startLine <= endLine; ++startLine) {
if (startLine % 2 == 0 && startLine != curSelected) {
// Draw the even and non selected rows.
graphics.setColor(LIGHT_TEXT);
graphics.drawShadedFilledPath(xInds, yInds, null, cols, null);
graphics.setColor(DARK_TEXT);
graphics.drawText((String) callBack.get(this, startLine), 0,
yInds[0]);
graphics.setColor(DARK_TEXT);
graphics.drawText((String) callBack.get(this, startLine), 200,
yInds[0]);
//graphics.setColor(DARK_TEXT);
} else {
// Draw the odd or selected rows.
graphics.setColor(DARK_TEXT);
graphics.drawText((String) callBack.get(this, startLine), 0,
yInds[0]);
}

// Assign new values to the y axis moving one row down.
y += rowHeight;
yInds[0] = y;
yInds[1] = yInds[0];
yInds[2] = y + rowHeight;
yInds[3] = yInds[2];
}
}