bonjour,
je suis entrain de developper une application pour blackberry, cette application comporte 2 ercants, le 1er est une fenetre "helloword" qui contien un menu dont lequel il ya "liste" une fois cliquer sur "liste" j'obtien un autre ecran qui affiche une liste des éléments de 1 a 5 , avec altérnance de couleur; en gros c'est ça ce que je veux faire,
le code qui affiche le 1er ecran se situ dans un fichier qui s'appel "HelloWorldDemo.java" et voici son code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package com.rim.samples.device.helloworlddemo;

import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.RichTextField;


/*
 * BlackBerry applications that provide a user interface must extend 
 * UiApplication.
 */
public class HelloWorldDemo extends UiApplication
{
    
    /**
     * Entry point for application. 
     */
    public static void main(String[] args)
    {
        // Create a new instance of the application.
        HelloWorldDemo theApp = new HelloWorldDemo();
        
        
        // To make the application enter the event thread and start processing messages, 
        // we invoke the enterEventDispatcher() method.
        theApp.enterEventDispatcher();
    }

    /**
     * <p>The default constructor. Creates all of the RIM UI components and pushes the
     * application's root screen onto the UI stack.
     */
    public HelloWorldDemo()
    {
        // Push the main screen instance onto the UI stack for rendering.
        pushScreen(new HelloWorldScreen());
    }    
}


/**
 * Create a new screen that extends MainScreen, which provides default standard
 * behavior for BlackBerry applications.
 */
/*package*/ final class HelloWorldScreen extends MainScreen
{

    /**
     * HelloWorldScreen constructor.
     */
    public HelloWorldScreen()
    {
        // Add a field to the title region of the screen. We use a simple LabelField 
        // here. The ELLIPSIS option truncates the label text with "..." if the text 
        // is too long for the space available.
        LabelField title = new LabelField("ADICHE Tewfik" , LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
        setTitle(title);

        // Add a read only text field (RichTextField) to the screen.  The RichTextField
        // is focusable by default.  In this case we provide a style to make the field
        // non-focusable.
        add(new RichTextField("Salut c'est moi ramanov,\n et c'est mon 1er programme blackberry!" ,Field.NON_FOCUSABLE));

        addMenuItem (new MenuItem("liste" , 5, 5)           
            {
                public void run()
                {
                   ///////////////////////////////////////////////////////
                   //que faut il metre ici pour aficher l'ecran qui contien
                  // la liste ?
            
                   
                   
                   ///////////////////////////////////////////////////////                                  
                }
            });
    }
 

    /**
     * Display a dialog box to the user with "Goodbye!" when the application 
     * is closed.
     * 
     * @see net.rim.device.api.ui.Screen#close()
     */
    public void close()
    {
        // Display a farewell message before closing application.
        Dialog.alert("Goodbye!");
        System.exit(0);       
        super.close();
    }      
}
le code qui affiche la liste (avec altérnance de couleur entre les items) se situ dans 2 fichier qui sont :
fichier 1 : "ColouredListField.java" dont le code est :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
 
package com.samples.colourListField;
 
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.Graphics;
 
public class ColouredListField extends ListField 
{
 
    private static final int LIGHT_TEXT  = Color.WHITE;
    private static final int DARK_TEXT  = Color.BLACK;
    private static final int BACKGROUND  = Color.DARKBLUE;
    private static final int HIGHLIGHT   = Color.GREEN;
    private final int[] cols = new int[]{BACKGROUND,HIGHLIGHT,LIGHT_TEXT,BACKGROUND};
    private boolean hasFocus;   //=false
 
    public ColouredListField() 
    {
        super();
    }
 
    public ColouredListField(int size)
    {
        super(size);
    }
 
    public ColouredListField(int numRows, long style) 
    {
        super(numRows,style);
    }
 
    //Handles moving the focus within this field.
    public int moveFocus(int amount, int status, int time) 
    {
        invalidate(getSelectedIndex());
        return super.moveFocus(amount,status,time);
    }
 
    //Invoked when this field receives the focus.
    public void onFocus(int direction) 
    {
        hasFocus = true;
        super.onFocus(direction);
    }
 
    //Invoked when a field loses the focus.
    public void onUnfocus() 
    {
        hasFocus = false;
        super.onUnfocus();
        invalidate();
    }
 
    //Over ride paint to produce the alternating colours.
    public void paint(Graphics graphics) 
    {
        //Get the current clipping region as it will be the only part that requires repainting
        XYRect redrawRect = graphics.getClippingRect();
        if(redrawRect.y < 0)
        {
            throw new IllegalStateException("Clipping rectangle is wrong.");
        }
 
        //Determine the start location of the clipping region and end.
        int rowHeight = getRowHeight();
 
        int curSelected;
 
        //If the ListeField has focus determine the selected row.
        if (hasFocus) 
        {
             curSelected = getSelectedIndex();
        } 
        else 
        {
            curSelected = -1;
        }
 
        int startLine = redrawRect.y / rowHeight;
        int endLine = (redrawRect.y + redrawRect.height - 1) / rowHeight;
        endLine = Math.min(endLine, getSize() - 1);
        int y = startLine * rowHeight;
 
        //Setup the data used for drawing.
        int[] yInds = new int[]{y, y, y + rowHeight, y + rowHeight};
        int[] xInds = new int[]{0, getPreferredWidth(), getPreferredWidth(), 0};
 
        //Get the ListFieldCallback.
        //This sample assumes that the object returned by the get
        //method of the callback is a String or has a toString method.
        //If this is not the case you will need to add the required logic
        //for your implementation.
        ListFieldCallback callBack = this.getCallback();
 
        //Draw each row
        for(; startLine <= endLine; ++startLine) 
        {               
            if (startLine % 2 == 0 && startLine != curSelected) 
            {
             //Draw the even and non selected rows.
                graphics.setColor(LIGHT_TEXT);
                graphics.drawShadedFilledPath(xInds, yInds, null, cols, null);
                graphics.drawText((String)callBack.get(this, startLine), 0, yInds[0]);
                graphics.setColor(DARK_TEXT);
            } 
            else 
            {
                //Draw the odd or selected rows.
                graphics.drawText((String)callBack.get(this, startLine), 0, yInds[0]);
            }
 
            //Assign new values to the y axis moving one row down.
            y += rowHeight;
            yInds[0] = y;
            yInds[1] = yInds[0];
            yInds[2] = y + rowHeight;
            yInds[3] = yInds[2];
        }
    }
}
fichier 2 :"ColourListFieldSample.java" dont le code est :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
 
package com.samples.colourListField;
 
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
import java.util.Vector;
 
class ColourListFieldSample extends UiApplication implements ListFieldCallback
{
    private static final String[] _elements = {"element 1", "element 2", "element 3", "element 4", "element 5"};
 
 
    private Vector _listElements = new Vector(_elements.length, 1);
 
    public static void main(String args[])
    {
        ColourListFieldSample theApp = new ColourListFieldSample();
        theApp.enterEventDispatcher();
 
 
    }
 
    ColourListFieldSample() 
    {    
        MainScreen myScreen = new MainScreen();
        myScreen.setTitle(new LabelField("Colour ListField sample"));
 
                            myScreen.addMenuItem(new MenuItem("quiter" , 5, 5)
            {
                public void run()
                {
                   Dialog.alert("Goodbye!");                                       
                }
            });
        ColouredListField colourList = new ColouredListField();
 
 
 
 
        //Set the ListFieldCallback
        colourList.setCallback(this);
 
        int elementLength = _elements.length;
 
        //Populate the ListField & ListFieldCallback with data.
        for(int count = 0; count < elementLength; ++count)
        {
            colourList.insert(count);
            this.insert(_elements[count], count);
        }
 
        //Add the ListField to the screen.
        myScreen.add(colourList);
 
        //Push the screen onto the display stack.
        pushScreen(myScreen);
 
    }
 
    //Draws the list row.
    public void drawListRow(ListField list, Graphics g, int index, int y, int w) 
    {
        //We don't need to draw anything here because it is handled
        //by the paint method of our custom ColouredListField.
    }
 
    //Returns the object at the specified index.
    public Object get(ListField list, int index) 
    {
        return _listElements.elementAt(index);
    }
 
    //Returns the first occurence of the given String, bbeginning the search at index, 
    //and testing for equality using the equals method.
    public int indexOfList(ListField list, String p, int s) 
    {
        //return listElements.getSelectedIndex();
        return _listElements.indexOf(p, s);
    }
 
    //Returns the screen width so the list uses the entire screen width.
    public int getPreferredWidth(ListField list) 
    {
        return Graphics.getScreenWidth();
    }
 
    //Adds a String element at the specified index.
    public void insert(String toInsert, int index) 
    {
        _listElements.insertElementAt(toInsert, index);
    }
 
    //Erases all contents.
    public void erase() 
    {
        _listElements.removeAllElements();
    }
}
le problème est qu'est ce qu'il faut metre dans la partie que j'ai préciser dans le fichier "HelloWorldDemo.java" (au niveau du menu = item = liste) pour afficher la liste ?
c'est a dire qu'une fois executer l'application affiche l'ecran hellowword, et si je selectionne dans le menu "liste" je veux avoire comme résultat l'affichage d'un autre ecran qui contien la liste , quel code doitj ecrire pour avoire cela ?

pour les codes que j'ai mis sont fourni avec d'autres dans les examples de "blackberry JDE " .