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
Highlighted
Developer
Posts: 32
Registered: ‎12-12-2008
My Device: Not Specified
Accepted Solution

ObjectChoiceField

Darn...Darn...

I do not like to "hard code" anything...  but I have a mainscreen with the following hard code:
_________________
    public class MyContextField extends RichTextField
    {
        private MenuItem myTideStations = new MenuItem(
            "Select a Tide Station: ", 50, 8) {
                public void run() {
                    onTideStations();
                }
            };
   
        private MenuItem myContextMenuItemB = new MenuItem(
            "Select a Date: ", 50, 8) {
                public void run() {
                    onMyMenuItemB();
                }
            };
_________________
         public void onTideStations()
        {
            MainScreen tideStations = new MainScreen();
            TideStations station = new TideStations();
            int numOfStations = station.LoadStations();
            String[] allStations = new String[numOfStations];
            for(int i = 0; i < numOfStations; i++)
                allStations[i] = station.getStation(i).station;

            ObjectChoiceField selectedStation = new ObjectChoiceField(
                "Select a tide Station:", allStations, 0);
            pushScreen(tideStations);
            selectedStation.setChoices(allStations);
            tideStations.invalidate();
            tideStations.add(selectedStation);

            selectedStation.getChangeListener();
            //int ObjectChoiceFieldIndex = selectedStation.getSelectedIndex();
            //Dialog.alert("You chose" + allStations[ObjectChoiceFieldIndex]);
            //tideStations.close();
            };
________________

After I "Select a Tide Station: ", the new MainScreen Menu displays the first "station" and I have to "click" to see a MenuItem "Change Option" :-(
Why don't I see all the "Tide Stations" the first time in?

The "invalidate" code was just to try anything. Maybe drop the "extends RichTextField"???

Help?

Austin

BlackBerry Development Advisor
Posts: 15,727
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: ObjectChoiceField

An ObjectChoiceField displays the currently selected choice.  When it is clicked on it expands to show all choices, allowing the user to pick something different.  Or if you press the menu key you can use the "Change Option" option in the menu.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 32
Registered: ‎12-12-2008
My Device: Not Specified

Re: ObjectChoiceField

Mark,

 

Thank you for that info.  I have already rewritten my code and am adding MenuItems.  I am programming for the 8700.  Next the 8800 to select locations using GPS.  The 8800 has the menu key, but I don't see it on my 8700 (actually my simulator is the 7290).

 

I thought I was going nuts... how do I give Kudos?

 

Austin

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: ObjectChoiceField

On the 8700, you need to listen for the navigationClick()

 

I have a utility method that tells me if there is a menu key on the device (looks at the model number and returns true or false).

 

If there is no menu key, then you invoke the menu on the click by calling the onMenu() method in your screen class.