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
Contributor
cartouche
Posts: 22
Registered: ‎03-19-2013
My Device: curve

GridField in Simple List

hi is it possible to integer grid field ( manager of colones ) in a simple liste ?

here is a test but it does not work :

 

package mypackage;

import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.component.table.SimpleList;
import net.rim.device.api.ui.container.GridFieldManager;
import net.rim.device.api.ui.container.MainScreen;

/**
 * A class extending the MainScreen class, which provides default standard
 * behavior for BlackBerry GUI applications.
 */
public final class MyScreen extends MainScreen
{
    /**
     * Creates a new MyScreen object
     */
    Activity Ac [] = new Activity[5];
    LabelField lblI = new LabelField();
    LabelField lbln = new LabelField();
    LabelField lbld = new LabelField();
     int j ;
     
    public MyScreen()
    {        
        // Set the displayed title of the screen       
        setTitle("Grid List");
        
        
        for(int i=0 ; i<5 ;i++)
        {
            Ac[i] = new Activity("nom","descr");
            Ac[i].Id = i+1;
        }
        
        GridFieldManager Gridlist = new GridFieldManager(6,3, 0);
        
        SimpleList liste = new SimpleList(Gridlist);
        
        for( j=0 ;j<5;j++)
        {
            lblI = new LabelField(Integer.toString(Ac[j].Id),Field.FOCUSABLE);
            lbln = new LabelField(Ac[j].name,Field.FOCUSABLE);
            lbld = new LabelField(Ac[j].descr,Field.FOCUSABLE);
            Gridlist.add(lblI);
            Gridlist.add(lbln);
            Gridlist.add(lbld);
        }
         
            
            liste.equals(Gridlist);
             liste.getView();
        
    }
}

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: GridField in Simple List

You asked:

"is it possible to integer grid field ( manager of colones ) in a simple liste ?"

 

Sorry this doesn't make sense to me.  You could be asking a number of things. I think the most likely quesitons are

a) Is it possible to use a SimpleList in a GridFieldManager?
Yes - theoretically you can add a SimpleListField as an element in a GridFieldManager, but the result is likely to be useless.  So I can't see that anyone will ever do it. 

b) Is it possible to add a GridFieldManager to a SimpleList?

No - but then the API should have told you this anyway - where is the method to add a FIeld to a SimpleList?

 

You said

"here is a test but it does not work :"

This is not a useful question.  This is like saying telling a mechanic "my car does not work - can you tell me why not"?  Have you given the mechanic enough information?

 

I suspect you will find the following a useful read. 

http://www.catb.org/esr/faqs/smart-questions.html

 

 I have highlighted some sections for you.

http://www.catb.org/esr/faqs/smart-questions.html#before

http://www.catb.org/esr/faqs/smart-questions.html#writewell

http://www.catb.org/esr/faqs/smart-questions.html#symptoms

http://www.catb.org/esr/faqs/smart-questions.html#code

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: GridField in Simple List

I asked a colleague what you might mean by this question and she had an interesting take.  She wondered if you wanted a table that was a row of integers with a number of columns.  She also wondered if you were using something like Google translator to create your questions and that was why it was not clear. 

 

Anyway, it looks like you have managed to get a table with integer columns using the GridFieldManager.  I have corrected your code (see below) and I get the attached screen.  Does this help?

 

Corrected code: 

package mypackage;

import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.component.table.SimpleList;
import net.rim.device.api.ui.container.GridFieldManager;
import net.rim.device.api.ui.container.MainScreen;

/**
 * A class extending the MainScreen class, which provides default standard
 * behavior for BlackBerry GUI applications.
 */
public final class MyScreen extends MainScreen
{
    /**
     * Creates a new MyScreen object
     */
    Activity Ac [] = new Activity[5];
    LabelField lblI = new LabelField();
    LabelField lbln = new LabelField();
    LabelField lbld = new LabelField();
     int j ;
     
    public MyScreen()
    {        
        // Set the displayed title of the screen       
        setTitle("Grid List");
        
        
        for(int i=0 ; i<5 ;i++)
        {
            Ac[i] = new Activity("nom","descr");
            Ac[i].Id = i+1;
        }
        
        GridFieldManager Gridlist = new GridFieldManager(5,3, GridFieldManager.AUTO_SIZE);
        
        // SimpleList liste = new SimpleList(Gridlist);
        
        for( j=0 ;j<5;j++)
        {
            lblI = new LabelField(Integer.toString(Ac[j].Id),Field.FOCUSABLE);
            lbln = new LabelField(Ac[j].name,Field.FOCUSABLE);
            lbld = new LabelField(Ac[j].descr,Field.FOCUSABLE);
            Gridlist.add(lblI);
            Gridlist.add(lbln);
            Gridlist.add(lbld);
        }
        
        this.add(Gridlist);
         
            
        //     liste.equals(Gridlist);
        //      liste.getView();
        
    }
}
class Activity extends Object {
	public String name;
	public String descr;
	public int Id;
	public Activity(String name, String descr) {
		this.name = name;
		this.descr = descr;
	}
}