Search This Blog

Tuesday, 29 May 2012

How to use GridFieldManager in Blackberry

Hello friends,
                   What you mostly do when you are supposed to display some data in a table form?....i was asking this same question till yesterday....but i got something called "GridFieldManager".I am still learning the functions of this field and will update you soon.But for now,Here is the simple code to add a GridFieldManager and add data to it.....Follow the Code:


In your Screen or you can say java file , where you want to display the GridFieldManager,declare the object first....

GridFieldManager _grid;

Now, initialize it .....

_grid = new GridFieldManager(10,4,0); <arg0=int rows,arg1=int columns,arg2=int style>

Now lets ur give some padding to rows and columns.....

_grid.setColumnPadding(5); <5 pixels>

Now let's give these columns fixed we have 4 columns as we declared while initializing the GridFieldManager,I'll divide the screen Width into 4 parts.....

_grid.setColumnProperty(0,GridFieldManager.FIXED_SIZE,Display.getWidth()/4-5)<arg0=int Column,arg1=int Property,arg2=value>

Remember you need to set the columnproperty individually for every column,with this you can give a different fixed size to columns.....

Now , lets set Padding for rows........


Now,simply add the Data to this GridFieldManager.....

_grid.add(new LabelField("One"));
_grid.add(new LabelField("Two));
_grid.add(new LabelField("Three"));
_grid.add(new LabelField("Four"));
_grid.add(new LabelField("Five"));
_grid.add(new LabelField("Six"));

Finally , add this GridFieldManager to the screen.....or layout wherever you want....



Try this code and check the output...

No comments:

Post a Comment