11-07-2008 12:43 AM
Could anyone please help me on this. I want to have a multi-column list view control in my blackberry form; just like a ListView control in .NET applications development.
I tried using ObjectListField but I am not able to succeed.
11-12-2008 02:41 PM
The BlackBerry API set doesn't contain any built in field that displays muli column lists. You could create a series of columns using managers. Have a look at the screen used in this sample for an example.
11-13-2008 12:34 AM
A number of the apps that come with the Blackberry--notably the mail reader--show what appears to be tabular data with multiple columns. It would be very helpful if you could tell us how the Blackberry engineers implement that. What do they do to get the columns lined up and to truncate long items with the ellipses? How do they get icons into a column?
As someone who comes from Java SE programming (where the standard components automatically take care of these tedious details), it is a bit unclear how much can be obtained from the BB components and how much must be hand-coded.
11-13-2008 05:57 AM
I suspect the majority of the applications that you are thinking of use ListField. You can tell a ListField because the entire row is selected when you scroll down to it. It is not possible to select a 'cell' in that row, though it does look like there is tabular data because the columns line up.
With ListField, there is a drawListRow method that gets called with an index (index to the entry that should be drawn) and a graphics 'rectangle' into which it can be drawn. This method can do what it likes in here, so for example, can decide to display some data starting at pixel position 100 in the x axis - this is how you get what looks like tabular data.
So to use this control, you need to understand the methods that are available to draw stuff onto a Graphic rectangle.
Look for examples on this forum and elsewhere of using ListField.
As quick examples consider the following:
graphics.drawText(aString, 0, y, (DrawStyle.LEFT + DrawStyle.ELLIPSIS + DrawStyle.TOP), 200 );
// Draw the String starting on the left hand side (position 0) for a maximum of 200 pixels
// Give the String an ellipsis if it is too long
graphics.drawBitmap(200, y, icon.getWidth(), icon.getHeight(), icon, 0, 0);
// Draw the icon at x position 200