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
leonsas
Posts: 28
Registered: ‎02-18-2010
My Device: 8520
My Carrier: Movistar

ObjectListField evenListener help

Hello, I'm trying to do my first App.

When the user changes the option of the seleccion ObjectListField I want to be able to know what he changed it to so I can do some other code, but I'm having troubles implementing the listeners.

Any help is appreciated.

ObjectChoiceField seleccion = new ObjectChoiceField("Select a unit", unidades);
add(seleccion);
seleccion.setChangeListener(new ButtonListener());

protected void setChangeListener(new ButtonListener())
            {
               private class ButtonListener implements FieldChangeListener
                 {
                   public void fieldChanged(Field field, int context)
                      {
                       if(context != FieldChangeListener.PROGRAMMATIC)
                          {
                            if(field.equals(seleccion))
                             {
                               //Some code here    
                             }
                           }
                      }
                   }

            };

 

Thanks!

 

Please use plain text.
Developer
PoojaMaheshwari
Posts: 141
Registered: ‎02-10-2010
My Device: 9500
My Carrier: Airtel

Re: ObjectListField evenListener help

Your question is on ObjectListField and your code uses ObjectChoiceField. Please clarify.

 

Looking at the code, the creation of method setChangeListener looks wrong. You simply need to create class ButtonListener that implements fieldChanged.

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: ObjectListField evenListener help

I use FieldChangeListener with ObjectChoiceField a lot - it seems to work for me.  What problems are you having?

Please use plain text.
Contributor
leonsas
Posts: 28
Registered: ‎02-18-2010
My Device: 8520
My Carrier: Movistar

Re: ObjectListField evenListener help

This is the error I get:

illegal start of expression
        public class ButtonListener implements FieldChangeListener
        ^
1 error

Please use plain text.