Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
Is there any way to add grid view in blackberry, plz help me for this
Posted

1 solution

Below code helps you to create grid view :-

Java
public final class gridFieldDemoScreen extends MainScreen
{
	LabelField one, two, three, four, five, six;
	public gridFieldDemoScreen()
    {
        setTitle("gridFieldDemo");   
        GridFieldManager grid = new GridFieldManager(2, 3, 0); // add number of rows and columns you want in ur grid i.e in this i take row = 2 and column = 3
        one = new LabelField("ONE");
        grid.insert(one, 0);  // this statement will add text to the grid and 0 is for position means index position of a text
        two = new LabelField("TWO");
        grid.insert(two , 1);
        three = new LabelField("THREE");
        grid.insert(three, 2);
        four = new LabelField("FOUR");
        grid.insert(four, 3);
        five = new LabelField("FIVE");
        grid.insert(five, 4);
        six = new LabelField("SIX");
        grid.insert(six, 5);
        grid.setColumnPadding(20); // this will use for gap between one grid element to other
        grid.setRowPadding(20);
        add(grid); // this will add grid to the screen
    }
}
 
Share this answer
 
v2
Comments
AmanArora1987 12-Sep-12 4:40am    
may be this code not works on simulator so try to use it on your device
Joan M 12-Sep-12 4:44am    
6 minutes of difference between the question and the answer... apart of that completely non documented neither explained.
Joan M 12-Sep-12 4:45am    
Oh, and we can't test (we don't want to) into our simulator and we have to do it directly on our device... If you want to post tips and tricks, there's a section for doing that, this area is to ask real questions to real problems.
AmanArora1987 12-Sep-12 4:50am    
i am trying that code on system, but when i tried that on device that works, thats why 6 mins difference is there..
Joan M 12-Sep-12 4:53am    
You are posting questions and after less than nothing the answers... this is possible once, but not as often like you are doing, you are posting incomplete/unclear questions and then a code dump. This is not how you should do it, if you've solved it for yourself then add a correct explanation, if not, delete the question, you are making CP quality to go low by doing that, this is why you are getting downvoted. If you want to explain the users how to do something (which is what it seems) then you should not add a question, you should start with tips and tricks, probably it will be well received. Posting a small introduction and some information on how to achieve things and why you've reached that conclusion...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900