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: 298
Registered: ‎05-02-2010
My Device: Bold 9700
My Carrier: Verizon
Accepted Solution

ListField.drawListRow only draws a line in the first row, not all of the rows.

[ Edited ]

I'm close. ListField.drawListRow is being called for each row without issue, but the two graphics.drawLine only are displayed (drawn) in the first row at the coordinates noted.

 

I thought that each row would get the two drawLines drawn?

 

Graphics.clear() is being called correctly (As a test only - I commented them out as well, but no changes).

 

How do I get the two Graphics.drawLine at the bottom of the method called for each row, correctly?

 

 

public void drawListRow(ListField listField, Graphics graphics, int index,
		int y, int width) {
	Logger.debug("CoffeeStoreContent [drawListRow] y: " + y + " width: " + width);
	/*
	 * Top Margin
	 */
	y += appGraphics.calcHiRes(6);

	int[] colors = appGraphics.getColorPalette(sportTitle);

	/*
	 * Get the current CoffeeStore object.
	 */
	CoffeeStore currentRow = (CoffeeStore) get(listField, index);

	StringBuffer subline = new StringBuffer(currentRow.getSource());
	subline.append(Characters.SPACE);
	subline.append("|");
	subline.append(Characters.SPACE);
	subline.append(currentRow.getDateAgo());

	int HiX = 43;

	if (graphics.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS)) {
		graphics.clear();
		graphics.setColor(AppGraphics.YELLOW_HIGHLIGHT);
		graphics.fillRect(0, (index * listField.getRowHeight()),
				listField.getWidth(), listField.getRowHeight());

		graphics.setFont(font);
		graphics.setColor(Color.BLACK);
		graphics.drawText(currentRow.getLinkText(), HiX, y, 0, width);

		graphics.setColor(AppGraphics.TEIGHT);
		graphics.drawText(subline.toString(), HiX, (y
				+ graphics.getFont().getHeight() + 2), 0, width);
	} else {
		graphics.clear();
		graphics.setColor(colors[0]);
		graphics.fillRect(0, (index * listField.getRowHeight()),
				listField.getWidth(), listField.getRowHeight());

		graphics.setFont(font);
		graphics.setColor(AppGraphics.TSIX);
		graphics.drawText(currentRow.getLinkText(), HiX, y, 0, width);

		graphics.setColor(Color.WHITE);
		graphics.drawText(subline.toString(), HiX, (y
				+ graphics.getFont().getHeight() + 2), 0, width);
	}
	
	graphics.setColor(colors[2]);
	graphics.drawLine(0, 50, width, 50);
	graphics.setColor(colors[3]);
	graphics.drawLine(0, 51, width, 51);
}

 

 

--Todd

Windows 7 Enterprise 64-bit (6.1 Build 7600) | Java SE Runtime Environment (build 1.6.0_24-b07) | Eclipse Version: 3.6.2 [M20110210-1200] | BlackBerry Eclipse Plug-in: 1.3.0.201102031007-19 | Java Compiler level: 1.3 | Targeting devices running OS 5 | Simulators: JDE 5.0 packaged 9700, 9630, 9300
Highlighted
Developer
Posts: 604
Registered: ‎12-27-2010
My Device: Not Specified

Re: ListField.drawListRow only draws a line in the first row, not all of the rows.

[ Edited ]

Looks like you're forgetting to use y when calculating the position of the line. Something along the lines of y + 50 [Edit: Thanks arkadyz!] should do it.

Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: ListField.drawListRow only draws a line in the first row, not all of the rows.

No - just y + 50 is enough.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Developer
Posts: 604
Registered: ‎12-27-2010
My Device: Not Specified

Re: ListField.drawListRow only draws a line in the first row, not all of the rows.

[ Edited ]

Err yeah, good catch arkadyz. Been working on Windows Embedded and my head is a little fuzzy!

Developer
Posts: 298
Registered: ‎05-02-2010
My Device: Bold 9700
My Carrier: Verizon

Re: ListField.drawListRow only draws a line in the first row, not all of the rows.

Crud, crud, crud!

Sorry to had post this, I missed that.

--Todd

Windows 7 Enterprise 64-bit (6.1 Build 7600) | Java SE Runtime Environment (build 1.6.0_24-b07) | Eclipse Version: 3.6.2 [M20110210-1200] | BlackBerry Eclipse Plug-in: 1.3.0.201102031007-19 | Java Compiler level: 1.3 | Targeting devices running OS 5 | Simulators: JDE 5.0 packaged 9700, 9630, 9300