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
ravi1989
Posts: 773
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

Please use plain text.
Developer
simon_hain
Posts: 15,806
Registered: ‎07-29-2008
My Device: Z10 LE
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
Please use plain text.
Developer
ravi1989
Posts: 773
Registered: ‎07-21-2012
My Device: 9810
My Carrier: 0

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

any other example..:smileysad:

Please use plain text.
Developer
simon_hain
Posts: 15,806
Registered: ‎07-29-2008
My Device: Z10 LE
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
Please use plain text.
Developer
ravi1989
Posts: 773
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..?

Please use plain text.
Developer
ravi1989
Posts: 773
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 

Please use plain text.
Developer
simon_hain
Posts: 15,806
Registered: ‎07-29-2008
My Device: Z10 LE
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
Please use plain text.
Developer
ravi1989
Posts: 773
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 

Please use plain text.
Developer
simon_hain
Posts: 15,806
Registered: ‎07-29-2008
My Device: Z10 LE
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
Please use plain text.
Developer
ravi1989
Posts: 773
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];
}
}

Please use plain text.