ObjectChoiceField and FieldChangeListener

I'm creating an application (Storm 9530 component package 4.7) that uses an ObjectChoiceField which is filled by anywhere from 1 to 50 choice programming.  I would use the FieldChangeListener to generate a new pop-up screen based on the selection made by the user of the ObjectChoiceField.  Because the list can be quite long, the user may need to scroll the list to find their choice.  Each time the selection is changed in the FieldChangedListener is called, but I want only to take action in the final selection is made ("clicked").  I have been in charge of the search and search but have not found the key to understand the current state of the ObjectChoiceField (open or closed).  Any help would be greatly appreciated.

TIA,

Tim

You will not be able to differentiate between these types of changes within a FieldChangeListener.  Instead, you might have the user selects an entry and use a ButtonField or MenuItem to check their choice.  Or you could have your action occur when the focus is moved out of the ObjectChoiceField.

Tags: BlackBerry Developers

Similar Questions

  • Strange: Objectchoicefield and ObjectListField in Gridfieldmanager - navigation problem

    Hi @all,

    I have a very strange problem, because running Simulator runs as I would have liked, but the device, the navigation is bad:

    running OS 5.0.0.42 3 on device (BB9700) and the Simulator

    1. the building screen

    2. put verticalfieldmanager on it that contains the background image

    3. put gridscreenmanager (with a column - the problem is with more then one column, too) on the first position of the vfm

    4. turn objectchoicefield with 5 points on the 1st row of the gsm

    5. put the objectlistfield with 5 points on the second line of gsm

    Program running in the Simulator:

    View all as I prefer.

    The first objectchoicefield and beyond the objectlistfield.

    When I scroll with trackpad OCF Gets the focus first and after that the olf on its first line.

    I can scroll up and down, and everything's fine.

    Program running on the device:

    View all as I prefer.

    The first objectchoicefield and beyond the objectlistfield.

    When I scroll with trackpad OCF Gets the focus first and after that the olf on its first line.

    So far so good:

    When I scroll down to the olf, all things are working properly. For example, point 4 a now focus.

    Now, if I try to go back in the OLF, it should go back to article 3 of the olf, but this is the leap into objectchoicefield. After that, if I try to go back to the objectlistfield, it jumps directly to point 4, which he came before.

    If I don't put the objectchoicefield in the first row, everything works fine.

    What can I do?

    I did something wrong?

    All ideas are very appeciated.

    Thanks in advance.

    CUA

    Michael

    Well, I found it.

    I made a mistake in the application of my own gridfieldmanager navigationmovement method.

    What is already strange: I used the same gridfieldmanager within 2 screens in my application. First screen was working fine, the second one was bad. Same content in both screens.

    Sorry for that.

    Thank you for all.

    CUA

    Michael

  • ObjectChoiceField and ChoiceField$ ChangeOptionChoiceField classcastexception

    one line in fieldchangelistener of my ObjectChoiceField, I have this line:

    choice final int = (field) .getSelectedIndex ((ObjectChoiceField));

    but he gives this exception:

    ClassCastException: Cannot mount net.rim.device.api.ui.component.ChoiceField$ ChangeOptionChoiceField (id = 91958272) at net.rim.device.api.ui.component.ObjectChoiceField

    How can I me index newly selected of the ObjectChoiceField in the Interior of the listener?

    I tried to use a final ObjectChoiceField so I could access it just inside the listener, but it I still get the value of previous for the selected index.

    my code:

    final distance ObjectChoiceField = new ObjectChoiceField ("Menu choose:", menu list);

    If (menuList.length > 1) {}
    Dialog.Alert ("length =" + menuList.Length);
    Flash = Integer.ToString (menu list [Dialog.ask ("which menu?", menuList, 0 "")] .getValue ());
    Dialog.Alert ("Flash =" + Flash);
    distance.setChangeListener (new FieldChangeListener () {}
    ' Public Sub fieldChanged (field field, int context) {}
    choice final int = (field) .getSelectedIndex ((ObjectChoiceField));
    Dialog.Alert ("get next choice");
    final int choice = distance.getSelectedIndex ();
    Dialog.Alert ("location =" + choices);
    Field.Get
    final int ctx = context;
    New Thread() {}
    public void run() {}
    loadMenus (ctx, choice);
    }
    }. start();
    }
    });

    objectSymbol = new ObjectChoiceField ("", ARRAY, 0, Field.FIELD_LEFT)
    {
    protected void fieldChangeNotify (int context)
    {
    indexCurrency = getSelectedIndex();
    }
    };

  • CheckboxField [] and fieldChangeListener.

    Hello

    I need a dynamic number of checkboxes for a project I'm working on. My code example is as follows. Somehow, I get an jvm stackoverflow exception.

    public class abc() extends screen implements {FieldChangeListener}

    CheckboxField [] boxField;

    public abc() {}

    .

    .

    .

    the length is variable.

    boxField = new CheckboxField [length];

    VFM VerticalFieldManager = new VerticalFieldManager();

    for (int i = 0; i)

    boxField [i] = new CheckboxField();

    boxField [i] .setChangeListener (this);

    VFM. Add (boxField [i]);

    }

    Add (VFM);

    }

    Sub fieldChanged (field field, int context) {}

    Hardcode for now. The intention is to loop through and uncheck all

    except one who was just ticked.

    chkBoxField [0] .setChecked (false); StackOverflow exception

    }

    }

    Help?

    In this way:

    chkBoxField [0] .setChecked (false);

    You set the value of the checkbox, prompting to advise its FieldChangeListener, which is to set the value of the box, which advises the FieldChangeListener... I could go on.   Until what I stack overflowed of course.

    Although there are many ways to stop this, I think that you should be aware of using the context provided to the fieldChanged method.  To check

    FieldChangeListener.PROGRAMMATIC

    If it matches, then the change was made by a program and not by the user, in which case you should ignore the change.

    For example:

    Sub fieldChanged (field field, int context) {}

    If (context == FieldChangeListener.PROGRAMMATIC) {}

    Only to process user changes to checkboxes

    return;

    }

    .....

    Hope it makes sense.

    Edit: this has been creating during the validation of RexDoug, my apologies for the repetition.

  • TouchEvent event and FieldChangeListener aid management

    I have a class screen that extends screen and implements FieldChangeListener. I have a function that captures

    TouchEvent.

    protected boolean touchEvent(TouchEvent te)

    I also have a function as implents FieldChangeListener

    ' Public Sub fieldChanged (field field, int context)

    I get all the touchevents in the touchEvent function, but once I did information there, I need to go to the normal processing, is there a way to implements this? or at least goto the function fieldChanged with the right parameters (scope, context)

    While when I click on an event, it goes to fieldChanged. I use picture.setChangeListener (this) to the fields I

    Thank you

    event management methods return true if the event has been consumed or handled and false otherwise.
    If you want the event to wander in the chain must return false in your implementation of tocuhEvent (I don't know if the touch events are addressed later)

  • Selection of savings between ObjectChoiceField and Hashtable

    I managed to save a text using EditField

    {if (profile1Hashtable.ContainsKey ("LastName"))}

    lastName.setText ((String) profile1Hashtable.get ("LastName"));

    }

    So I thought that to save a value (sex selector) would be

    {if (profile1Hashtable.ContainsKey ("Sex"))}

    sexChoiceField.setSelectedIndex ((Integer) profile1Hashtable.get ("Sex"));

    }

     

    But what is the code that I put in the save()?

    Its because I failed at the bis code 'new '.  Here's a corrected line:

    profile1Hashtable.put ("Sex", New Integer (sexChoiceField.getSelectedIndex ()));

  • Characters.Escape and ObjectChoiceField

    Hi all

    I made an app that has an ObjectChoiceField and when you select an index, she throws you to another screen filtering what you see according to the selected index.

    When you are in the new screen and the user, press the ESC key to go back, the ObjectChoiceField displays the index that the user has selected before, and I want the ObjectChoiceField to set the default index value, is it possible?

    Not convinced this Sad_Bird idea is very "as object".  I don't think you want 2 screen to worry about screen 1.

    A number of options come to mind, the manifesto being once you got the selected index and screen 2, then in Screen1, just created all the index selected in your ObjectChoiceField to 0.  You can do so after you press display 2.

  • Open objectChoiceField press ENTER, curve 8520 (JDE 5.0)

    Hello

    I added an objectChoiceField on horizontalfieldManager (hfm) and hfm is added to the main vericalfieldmanager.

    I click the trackpad, opens my objectChoiceField and I am able to make the selection,

    but when I press on enter (when ojectchoicefield is focused), the focus moves to the next field. I want to open choicefield when I press on enter the update choicefield.

    Thanks in advance.

    Thank you and best regards,

    Fekri

    I created this example... try what he's working on the press to enter the key

    SerializableAttribute public class HelloWorldScreen extends form {}

    ObjectChoiceField objectChoiceField;

    public HelloWorldScreen()
    {
    setTitle ("Screen Test");

    objectChoiceField = new ObjectChoiceField ("Test", new String [] {"1", "2", "3"});
    Add (objectChoiceField);

    }

    {} protected Boolean keyChar (char c, int status, int time)

    If (getFieldWithFocus () == objectChoiceField & c == Characters.ENTER) {}
    EventInjector.invokeEvent (new EventInjector.NavigationEvent (EventInjector.NavigationEvent.NAVIGATION_UNCLICK, 0, 0, status))

    ));
    }
    Returns true;
    }

    }

  • Objectchoicefield custom

    Hai all,
    I need to implement the button and label field of objectchoice with separate click to button and label (or listview complete) event, please give suggestions to implement the custom objectchoicefield.

    The name of the company must establish a click event to view the details and the distinct x (delete button) need separate, click event to remove the choice of listfield.

    Thank you.

    You ask a lot of us aren't you?

    I suggest you just start trying to do just one of these things, something code that you think the work and we could help you get the code works.

    But I must point out that I've never seen anything like that on the BlackBerry that works as an ObjectChoiceField and is the kind of thing you're after.  So I suspect that you maybe isn't able to implement features as requested, or if you can, it will take a lot of time.  You might think to simplify the obligation.

    Remember that an ObjectChoiceField is not a click event different for different parts of the drop down, so you won't be able to use it.  You need to create something else.  In this kind of situation, I have in the past, created a popup screen to display the values of 'pull down', but this clearly does not resemble a pull down, even if it provides the same functionality.

  • No discussion on objectchoicefield

    Hello friends

    I created 4 objectchoicefields and added to the screen. Now when I move the trackball, I can't focus on the fields. the focus remains on the raw itself.

    When I looked at the API documentation, he said "If you want your field receives focus, then you must override isFocusable to return true.

    So I created the objectchoicefield like this.

      showDialogTime = new ObjectChoiceField("Alerts Displayed For ",choiceNumbers,getTimeByInteger(),Field.FOCUSABLE)
            {
                public boolean isFocusable()
                {
                    return true;
                }
    
                protected void fieldChangeNotify(int context)
                {
                    if(context==2)
                    {
                        ApplicationSettings.getInstance().setStatusAlertTime(getIntFromString());
                    }
                }
                  public void paint(Graphics graphics)
            {
                    graphics.setColor(Constants.fontColor);
                    super.paint(graphics);
            }
            };
    

    but I still can't s focus.what the problem?

    Thank you... But I got it working as there was a mistake in my code... I overrided navigationmovement() and consume it the movement of the trackball. Sorry to bother guys. Thanks again

  • How to re - initialize an ObjectChoiceField.

    I usually Initializes an ObjectChoiceField like this:

    String [] message = GetMessageList();
    cboMessages = new ObjectChoiceField ("select a message," messages ");

    Add (cboPrinters);

    And it works very well.  However, later I want to delete all the entries and add a new list to the ObjectChoiceField.

    I can't seem to find how to clear the ObjectChoiceField and I see no way to insert new items?

    Am I missing something simple massively?

    Thank you.

    Try the method of setChoices (choice of Object []) ObjectChoiceField, so in your case, you would say

    cboMessages.setChoices (newList);

    General, I'm an invalidate() after that I did a setChoices(), just to make sure that the field is being updated on the screen.

  • ChoiceField help

    Hi here is my problem

    I've created a subclass (DynamicObjectChoice) that extends ObjectChoiceField and created an another subclass (MyObjectChoiceListener) that extends FieldChangeListener.

    In DynamicObjectChoice I crushed constructor and take an int parameter.

    Then in my main class, I've created a DynamicObjectChoice and fill in a loop like this.

    for (int i = 0; i < someInt; i++) { choiceFieldArray[i] = new DynamicObjectChoiceField(Label, choices, 0, i);
                MyObjectChoiceListener listener= new MyObjectChoiceListener();
                choiceFieldArray[i].setChangeListener(listener);
                add(choiceFieldArray[i]);}
    

    and crushed fieldChange MyObjectChoiceListener with this method.

    public void fieldChanged(Field field, int context) {
                System.out.println((DynamicObjectChoiceField)field).getLabel());
    }
    

    AND HE SAID CLASSCASTEXCEPTION! Why? im stuck here.  I have founfd that I have change

    System.out.println((DynamicObjectChoiceField)field).getLabel());
    

    TO

    System.out.println((ChoiceField)field).getLabel());
    

    It works but I need other methods that are available only on DynamicObjectChoiceField. Help, please!

    I solved this problem, but I don't understand why I should use it. I think that the event 'clone' the field being passed at run time, and when you try to cast it giives you classcast exception. Solution was this:

    ((DynamicObjectChoiceField) field.getOriginal()).getLabel();
    

    So in the hope that it helps someone else.

  • Tips for making a custom NumericChoiceField

    I had an ugly behavior with NumericChoiceFields and HorizontalFieldManager... So I want to create a custom that will change the background color and width. Can someone give me a suggestion about where to start? I guess it's a lot different, custom, then labelfields and others. Thank you!

    I thought that NumericChoiceField was a variant of ObjectChoiceField and taken as its width, the largest of its entries, so the width that you see is a surprise for me.  Something, I'll have to test, but I can't do it now.

    In regard to being on the right, if you use the Style

    Field.FIELD_HCENTER

    who should set the fields in the Center for you.

    As a test, you can create an ObjectChoiceField with just 1-5 as the selected objects, and I think it should be more restricted.  Let us know how you go with it.

    You can find you using your own Manager Simon suggests, but there may be a way around him in this case we should look at first.

  • Help: fieldChanged is not implemented

    Hello

    Please help me on this bug.

    I'm working on BB Storm2 9520, developing on JRE 5.0.0 not JRE (API) 6.0.0

    I created a class BaseScreen, which extends the screen and implements FieldChangeListener

    public abstract class BaseScreen extends MainScreen implements FieldChangeListener{    protected MToolbarButtonField btn1;    protected MToolbarButtonField btn2;    protected MToolbarButtonField btn3;    protected MToolbarButtonField btn4;    protected MToolbarButtonField btn5;    protected ToolbarManager toolbarManager;
    
        public BaseScreen() {        toolbarManager = new ToolbarManager();        HorizontalFieldManager hfm = new HorizontalFieldManager();        hfm.add(btn1);        hfm.add(btn2);        hfm.add(btn3);        hfm.add(btn4);        hfm.add(btn5);        toolbarManager.add(hfm);        setStatus(toolbarManager);    }
    
        public void fieldChanged(Field field, int context)     {        System.out.println("======== Toolbar Button Clicled ========");    }
    
    }
    

    Class MToolbarButtonField extends the ToolbarButtonField class:

    public class MToolbarButtonField extends ToolbarButtonField{    private Bitmap bmpIcon;
    
        public MToolbarButtonField(Bitmap bmp) {        super(Field.FOCUSABLE, bmp);        bmpIcon = bmp;    }
    
        protected void paint(Graphics g) {        //...    }}
    

    Class ToolbarButtonField extends the class of field:

    public class ToolbarButtonField extends Field{    private Bitmap bmpIcon;
    
        public ToolbarButtonField(long style, Bitmap bmp) {        super(style);        bmpIcon = bmp;    }
    
        protected void paint(Graphics g) {        //...    }
    
        protected boolean navigationClick(int status, int time)     {        fieldChangeNotify(1);        return true;    }
    
    }
    

    Then, I created some screens that extends the BaseScreen class and FieldChangeListener tools:

    public class Screen1 extends BaseScreen implements FieldChangeListener{    private BitmapButtonField btn1;    private BitmapButtonField btn2;
    
        public Screen1() {        btn1 = new          BitmapButtonField(Bitmap.getBitmapResource(               "bntmyinfos.png"),              Field.FOCUSABLE| FIELD_LEFT | FIELD_VCENTER);        btn2 = new BitmapButtonField(Bitmap.getBitmapResource(              "bntmycont.png"),              Field.FOCUSABLE| FIELD_LEFT | FIELD_VCENTER);    }
    
        public void fieldChanged(Field field, int context) {        System.out.println("==== Screen1 buttons clicked");        //...    }}
    

    When I clicked on the btn1, btn2 on Screen1, the Screen1.fieldChanged prints to the Console Windows "= Screen1 buttons clicked.

    But when I clicked the btn1 on toolbar, nothing happenned.

    I've already put the style buttons toolbarManager are FOCUSABLE so why nothing is there?

    What should I do to make the BaseScreen.fieldChanged took place?

    Everyone please help.

    Thanks in advance.

    Hi guys,.

    Thank you for your support.

    Now, I already solved the problem.

    And the solution is the fieldChangeNotify (int context) method.

    Add this method in the ToolbarButtonField class, and it works.

    Here is my code that worked:

    ToolbarButtonField

    public class ToolbarButtonField extends Field (    private Bitmap bmpIcon;
    
        public ToolbarButtonField(Bitmap bmp)    {        super(Field.FOCUSABLE);        bmpIcon = bmp;    }
    
        protected void fieldChangeNotify(int context) {           this.getChangeListener().fieldChanged(this, context);       }
    
        protected boolean navigationClick(int status, int time)     {        fieldChangeNotify(1);        return true;    }
    
        protected void paint(Graphics g)    {        //...    }    //...}
    

    and some changes: in BaseScreen, let the fieldChanged method do nothing, change the MToolbarButtonField of extends from ToolbarButtonField to implements FieldChangeListener, and then implement the fieldChanged here method:

    public class MToolbarButtonField implements FieldChangeListener {
        private Bitmap bmpIcon;
        private BaseScreen caller
        private ToolbarButtonField btn1;
        private ToolbarButtonField btn2;
        private ToolbarButtonField btn3;
        private ToolbarButtonField btn4;
        private ToolbarButtonField btn5;
        private VerticalFieldManager toolbarFieldManager;
    
        public MToolbarButtonField(BaseScreen caller) {
            this.caller = caller;
            toolbarFieldManager = new VerticalFieldManager();
    
            btn1 = new ToolbarButtonField();
            btn1.setChangeListener(this);
            btn2 = new ToolbarButtonField();
            btn2.setChangeListener(this);
            btn3 = new ToolbarButtonField();
            btn3.setChangeListener(this);
            btn4 = new ToolbarButtonField();
            btn4.setChangeListener(this);
            btn5 = new ToolbarButtonField();
            btn5.setChangeListener(this);
    
            toolbarFieldManager.add(btn1);
            toolbarFieldManager.add(btn2);
            toolbarFieldManager.add(btn3);
            toolbarFieldManager.add(btn4);
            toolbarFieldManager.add(btn5);
        }
    
        public void addToolbarToScreen()
        {
            caller.setStatus(toolbarFieldManager);
        }
    
        public void fieldChanged(Field field, int context)
        {
            if (field == btn1)
            {
                System.out.println("Button 1 clicked !");
            }
            if (field == btn2)
            {
                System.out.println("Button 2 clicked !");
            }
            if (field == btn3)
            {
                System.out.println("Button 3 clicked !");
            }
            if (field == btn4)
            {
                System.out.println("Button 4 clicked !");
            }
            if (field == btn5)
            {
                System.out.println("Button 5 clicked !");
            }
        }
    }
    

    BaseScreen:

    public abstract class BaseScreen extends MainScreen implements FieldChangeListener
    {
        MToolbar toolbarManager;
        /**
         * Creates a new MyScreen object
         */
        public BaseScreen()
        {
            // Set the displayed title of the screen
            setTitle("Toolbar Button display");
    
            toolbarManager = new MToolbar(this);
            toolbarManager.addToolbarToScreen();
        }
    }
    

    MyScreen (Screen1 last time):

    public class MyScreen extends BaseScreen {
        private ButtonField btn6;
        private ButtonField btn7;
    
        VerticalFieldManager vfm;
    
        public MyScreen()
        {
        vfm = new VerticalFieldManager();
        btn6 = new ButtonField("MyScr button 1", Field.FOCUSABLE);
        btn6.setChangeListener(new FieldChangeListener()
        {
            public void fieldChanged(Field field, int content)
            {
            Dialog.alert("My Screen's button 1 clicked!");
            }
        });
        vfm.add(btn6);
    
        btn7 = new ButtonField("MyScr button 2", Field.FOCUSABLE);
        btn7.setChangeListener(new FieldChangeListener()
        {
            public void fieldChanged(Field field, int content)
            {
            Dialog.alert("My Screen's button 2 clicked!");
            }
        });
        vfm.add(btn7);
    
        this.add(vfm);
        }
    }
    
  • lag performance

    Hello

    I worked on an application and I noticed that when I run on my device (8800), in some cases performance is very slow.

    I have a lot of choiceFields, and the first time I click on one to change the option, it takes 2-3 seconds to reject the choices menu. The next choiceField I click on works fine, it is still only the first who has the lag.

    I noticed the same thing if I invoke the context menu by clicking the blackberry button. When I try to remove the menu, it takes 2-3 seconds, and again once this happens only the first time I click to display the menu. If I try again, without stimulus the app, it's fast and works as expected.

    So here something that happens when the small menu disappears which causes a shift of the first time, that he has to go.

    My screen consists of the following:

    VerticalFieldManager (vertical scrollbar) x 1

    Custom Manager (no scrolling) x 1

    VerticalFieldManager (no scrolling) x 1

    horizontalFieldManager (no scrolling) x 15

    RichtextField, x 1, ObjectChoiceField x 1

    RichTextField x 1

    Any ideas?

    Thank you!

    Thanks for the link.

    It turns out that I have is the substitution of the method onExposed() of the ObjectChoiceField, and went down to the size of the font in this method and for some reason any caused it to slow down. Now, I have just a flag to reset the font size as needed, rather than always doing.

    Thanks again!

Maybe you are looking for

  • Cannot enter BIOS - Satellite-P50t-A-119

    Cannot get into the BIOS. F2 works Océ try 20 times. Same problem with the F8 key. I tried 30 times, it worked only once. Laptop is brand new.Is there a stable way to get into the Bios?Is there a stable way to use the F8 key. I never had problems lik

  • Driver Intel WiUSB doesn't work does not correctly?

    USB - IFxHCI Intel WiUSB USB host controller driver does not work properly because it has random (or whatever) yellow sign in management devices..., how can I get this driver? my laptop is a T430.

  • HP envy Touchsmart 20-d113w while a (90-degree display rotation)

    My screen has turned 90 degrees the same as if it were a cell phone. How can I get this back to the way it is supposed to be? I have no idea why it turned.  This is a new PC running Windows 8. Please help me. Thank you.

  • Manager updated - uninstall

    "Update Manager" appears when I start my computer, but I don't remember installing and it never appears to do anything. How can I remove this permandently?

  • HP Pavilion b101sd-15 Sleekbook HDMI does not work

    Hello I have a HP Pavilion b101sd-15 Sleekbook and my HDMI port does not work. I have already updated all my drivers, but this makes no sense. I hope there's someone on this forum who can help me. --------------------Sanderhttp://sanderwoudts.EU