ButtonField FieldChangeListener

Hello guys...

I hv created a button 'next' say... .NW I want tht on clickin button tht he shd go to next screen... for example... on my first screen I have a button if I click on it... i want him to goto next screen tht listfield and on listfieldscreen iwant a button called 'back' to return to the first screen... hw do?

Basically I want the following buttons and back to jump from one screen to another...

You can write to FieldChangeListener for the button like this,

ButtonField btn = new ButtonField ("Next");
btn.setChangeListener (new FieldChangeListener() {}
        
' Public Sub fieldChanged (field field, int context)
{
UiApplication.getUiApplication () .pushScreen (new ScreenName());
        
}
});

and on the next screen to create new buttonField and

on FieldChanged() write code for anti-pop.

Tags: BlackBerry Developers

Similar Questions

  • Vibratie unit

    Hello

    How can I vibrate the BB device as resullt of any action? I mean I want to vibrate the unit for 10 seconds by pressing a button. Is this possible? and how?

    Thank you in advance.

    Hello

    create a button. Add a ChangeListener to this button.

    In this following ButtonField FieldChangeListener do FIeldChanged method:

    Alert.startVibrate (10000);

    Kind regards

    Jochen

  • Editing a FieldChangeListener ButtonField to another button

    I need a few labels of button to change depending on their context. I can't change the label of a button of its own FieldChangeListener. But I would also update the label of an auditor of another button button. I get an error that the name of the button cannot be resolved.

    Error: btLap cannot be resolved.

    What Miss me?

    Thank you

    final ButtonField btStart = new ButtonField("Start");
    btStart.setChangeListener( new FieldChangeListener() {
        public void fieldChanged( Field field, int context ) {
            if (Timer.getState() != Timer.RUNNING) {
                Timer.start();
                btStart.setLabel("Stop");
                btLap.setLabel("Lap");
    
            } else {
                Timer.stop();
                btStart.setLabel("Start");
                btLap.setLabel("Reset");
    
            }
        }
    } );
    fmButtons.add(btStart);
    
    final ButtonField btLap = new ButtonField("Reset");
    btLap.setChangeListener( new FieldChangeListener() {
        public void fieldChanged(Field field, int context) {
            if (Timer.getState() == Timer.RUNNING) {
                Timer.lap();
                // ...
    
            } else {
                Timer.reset();
                // ...
    
            }
        }
    } );
    fmButtons.add(btLap);
    

    I'm sorry. It's late. Just to set the other button before using it! You place your order... doh!

    final ButtonField btStart = new ButtonField("Start");
    final ButtonField btLap = new ButtonField("Reset");
    
    btStart.setChangeListener( new FieldChangeListener( ) {
        public void fieldChanged( Field field, int context ) {
            if (Timer.getState() != Timer.RUNNING) {
                lapTimer.start();
                btStart.setLabel("Stop");
                btLap.setLabel("Lap");
                ...
    
  • FieldChangeListener on a ButtonField displays a prompt with named Application Switch and full Menu options dialog box. instead of the action set.

    Hi I use a ButtonField in my class of the screen and adds a ChangeListener and provided the measures required in

    fieldChanged(Field field, int context)
    

    method. But everytime that I click on a button, a dialog box invites you to two play as Application Switch options and full Menu.


    I think that there is a method that must be overridden to avoid this problem. I get this result when I run my app in the device with OS 5.0, but it works fine on the Simulator (7.0).

    Use ButtonField.CONSUME_CLICK as a style.

    your override of navigationclick should also work, but you would raise the event changed yourself field before return true.

  • TouchEvent & FieldChangeListener both does not work

    Hello

    I have 2 bitmapfields and a buttonfield. I want that all fields to intercept the click event. Initially, I had added only fieldChangeListeners to all fields, but bitmap field has not answered them (despite making them Focusable). I added touchevent to handle events click for all areas, now all fields respond only touchEvents. Same buttonfield does not meet fieldChange that he met before adding the touchEvent.

    Can someone help me to know the problem and the solution for the same. I want that all fields to react to events through contact or normal by a click. Also in touchEvent as navigationClick added id, if the menu is not coming, but otherwise with the other menu click only just who should not and the fieldchangelistener should be handled.  Here's the code.

        private BitmapField  signOffBtn, profileBtn;
        private ButtonField btn;
    
        public LoggedUserScreen(UserBean user) {
            super();
            this.loggedUser = user;
            System.out.println("Into LoggedUserScreen : Got user");
            init();
            this.add(signOffBtn);
            this.add(profileBtn);
            this.add(btn);
        }
    
        private void init() {
            signOffBtn = new BitmapField (Bitmap.getBitmapResource("icon.png"),  BitmapField.FOCUSABLE ) {
                protected boolean navigationClick(int status, int time) {
                    return true;    // handle click event
                }
            };
            profileBtn = new BitmapField (Bitmap.getBitmapResource("icon.png"),  BitmapField.FOCUSABLE ) {
                protected boolean navigationClick(int status, int time) {
                    return true;    // handle click event
                }
            };
            btn = new ButtonField("button", BitmapField.HIGHLIGHT_SELECT |  BitmapField.FOCUSABLE);
            signOffBtn.setChangeListener(this);
            profileBtn.setChangeListener(this);
            btn.setChangeListener(this);
        }
    
        public void fieldChanged(Field field, int context) {
            if (field == signOffBtn) {
                System.out.println("********* SIGN OFF CLICKED");
            } else if (field == profileBtn) {
                System.out.println("********* PROFILE CLICKED");
            } else if (field == btn) {
                System.out.println("********* button CLICKED");
                System.exit(0);
            }
        }
    
       public int getFieldAtLocation(int x, int y)    {
             XYRect rect = new XYRect();
             int index = getFieldCount() -1;
             while (index >= 0)        {
                getField(index).getExtent(rect);
                if (rect.contains(x, y))
                    break;
                 --index;
             }
             return index;
      }
    
      protected boolean touchEvent(TouchEvent event) {
    
          switch(event.getEvent()) {
              case TouchEvent.DOWN:
                return true;
              case TouchEvent.MOVE:
                return true;
              case TouchEvent.UP:
                return true;
              case TouchEvent.CLICK:
                int index = getFieldAtLocation(event.getX(1), event.getY(1));
                // Ignore click events outside any fields
                if (index == -1)
                    return true;
    
                Field field = getField(index);
                if (field == signOffBtn) {
                    System.out.println("Touched SignOff");
                } else if (field == profileBtn) {
                    System.out.println("Touched Profile");
                } else if (field == btn) {
                    System.out.println("Touched Button");
                }
                return true;
          }
          return false;
      }
    

    Thank you

    Ago I already watched this about such removeFocus or setFocus (false) or more. But yes, your something.setFocus gave me the idea to setFocus on the screen itself for the development is removed from the key also and not on any component capable of intercepting the event.

    So if I add fieldChangeNotify (0); in signOffBtn navigationclick, profileBtn & btn, then I totally don't need to implement the touchEvent?

        private void init() {
            signOffBtn = new BitmapField (Bitmap.getBitmapResource("icon.png"),  BitmapField.FOCUSABLE | ButtonField.FIELD_LEFT) {
                protected boolean navigationClick(int status, int time) {
                    fieldChangeNotify(0);
                    return super.navigationClick(status, time);    // handle click event
                }
            };
            profileBtn = new BitmapField (Bitmap.getBitmapResource("icon.png"),  BitmapField.FOCUSABLE | ButtonField.FIELD_RIGHT ) {
                protected boolean navigationClick(int status, int time) {
                    fieldChangeNotify(0);
                    return super.navigationClick(status, time);    // handle click event
                }
            };
            imageBtn = new ImageButton(Bitmap.getBitmapResource("icon.png"), Bitmap.getBitmapResource("icon.png"));
            btn = new ButtonField("button", BitmapField.HIGHLIGHT_SELECT |  BitmapField.FOCUSABLE | ButtonField.FIELD_RIGHT) {
                protected boolean navigationClick(int status, int time) {
                    fieldChangeNotify(0);
                    return super.navigationClick(status, time);    // handle click event
                }
            };
    
            signOffBtn.setChangeListener(this);
            profileBtn.setChangeListener(this);
            imageBtn.setChangeListener(this);
            btn.setChangeListener(this);
        }
    

    touchEvent is totally deleted & navigationClick is implemented for each button.

    Thank you. I just want to confirm, with this, my componetns everything will work for touch & non touch screen properly. 9530 Simulator touch screen reacts (left mouse click), but not touch that is a click (muose right clisk) does not do anything. So I was wondering...

  • FieldChangeListener does not not in OS6

    I have the following listener to perform an action to a button click event.  It works very well in OS5 devices, but nothing happens when you click the button in the OS6 devices.  Any ideas?

    ButtonField buttonSearch = new ButtonField("Search", ButtonField.CONSUME_CLICK)
            {
                public int getPreferredWidth()
                {
                    return Display.getWidth();
                }
            };
            FieldChangeListener listener = new FieldChangeListener() {
                public void fieldChanged(Field field, int context) {
                    final AddressInfo addrInfo = new AddressInfo();
    
                        addrInfo.setField(AddressInfo.STREET, street.toString());
                        addrInfo.setField(AddressInfo.CITY, city.toString());
                        addrInfo.setField(AddressInfo.STATE, state.toString());
                        addrInfo.setField(AddressInfo.POSTAL_CODE, postal.toString());
                        addrInfo.setField(AddressInfo.COUNTRY, "United States");
                    geoCache(addrInfo);
                }
            };
            buttonSearch.setChangeListener(listener);
            add(buttonSearch);
    

    try to use this code: I use it on OS 6.0

    class xxxxxx extends MainScreen implements FieldChangeListener{    xxxxxx()    {        ButtonField buttonSearch = new ButtonField("Search", ButtonField.CONSUME_CLICK);        buttonSearch.setChangeListener(this);    }
    
        public void fieldChanged(Field field, int context)     {        if (field == buttonSearch)         {        }    }}
    
  • Question about FieldChangeListener

    Finally, I'm going back to rewrite the custom PopupScreen that I created for a blackberry app staff.

    I had a question on a FieldChangeListener I set myself for a button.

    The code looks like this:

    FieldChangeListener fcl = new FieldChangeListener()
    {
      public void fieldChanged(Field field, int context)
      {
        fieldChangeNotify(cancel) //cancel is a public static final int
        close();
      }
    };
    
    ButtonField.setChangeListener(fcl);
    

    My question is this: how to retrieve the context of int fieldChangeNotify (int context) value if the listener is attached to the key?

    I am tempted to write a method that mimics the method getSelectedValue() of the dialog class.

    I just wrote to follow him, not production code, but I need something similar to what you want (a dialog box I could put things in).  I hope you can use it, and it shows you how to enable a button in a return code.

    Note that the questionField is optional, basically, the idea is that this screen will be used when it is necessary to confirm an action and collect additional information.  You can ignore it.

    Here is an example of using the screen - I have; ve just done upwards, so please forgive the errors:

    BasicEditField _questionField = new BasicEditField ("reason for Deferring:", "");
    Create the popup to confirm the defer
    ConfirmActionPopupScreen caps = new ConfirmActionPopupScreen ("Confirm Report", _questionField);
    int response = caps.doModal ();
    If (int ==-1) {}
    cancelled
    } else {}
    Oudit
    String pattern = _questionField.getText ();
    ...
    }

    And here is the screen.  Note that I had to change a few things that are specific to what I do, so it would not work, but you get the idea.

    I hope it works for you.

    class ConfirmActionPopupScreen extends PopupScreen
                                   implements FieldChangeListener {
    
        private ButtonField _okButton = new ButtonField("OK");
        private ButtonField _cancelButton = new ButtonField("Cancel");
        private BasicEditField _questionField = null;
    
        private int _returnCode = -1; // Default to Cancel value
    
        //statics ------------------------------------------------------------------
        private static ResourceBundle _resources = ResourceBundle.getBundle(UIResource.BUNDLE_ID, UIResource.BUNDLE_NAME);
    
        public ConfirmActionPopupScreen(String confirmString, BasicEditField questionField) {
            super(new VerticalFieldManager(),Field.FOCUSABLE);
            // Question Icon and text on top
            HorizontalFieldManager hfm = new HorizontalFieldManager();
            hfm.add(new BitmapField(Bitmap.getPredefinedBitmap(Bitmap.QUESTION), BitmapField.FIELD_LEFT));
            hfm.add(new LabelField(" ")); // Just to space it a bit
            hfm.add(new RichTextField(confirmString, RichTextField.FIELD_HCENTER | RichTextField.FIELD_VCENTER ));
            this.add(hfm);
            this.add(new SeparatorField());
            // Optional Question
            _questionField = questionField;
            if ( _questionField != null ) {
                this.add(_questionField);
                this.add(new SeparatorField());
            }
            // Buttons at bottom
            hfm = new HorizontalFieldManager(Field.FIELD_HCENTER);
            hfm.add(_okButton);
            _okButton.setChangeListener(this);
            hfm.add(_cancelButton);
            _cancelButton.setChangeListener(this);
            add(hfm);
    
            // Focus on Question or Cancel Button
            if ( _questionField != null ) {
                _questionField.setFocus();
            } else {
                _cancelButton.setFocus();
            }
        }
    
        /**
         * Diaplay this Screen and wait for response
         * @return indicator of selected button
         */
        public int doModal() {
            UiApplication.getUiApplication().pushModalScreen(this);
            return _returnCode;
        }
    
        /**
         * Only used to process ESC as Cancel
         */
        public boolean keyChar(char key, int status, int time) {
            //intercept the ESC key - exit the app on its receipt
            boolean retval = false;
            switch (key) {
                case Characters.ESCAPE:
                    _returnCode = -1;
                    close();
                    return true;
            }
            return super.keyChar(key,status,time);
        }
    
        public void close() {
            UiApplication.getUiApplication().popScreen(this);
        }
    
        /**
         * Listen for Button press, and process accordingly.>
         */
        public void fieldChanged(Field field, int context) {
            if ( context == FieldChangeListener.PROGRAMMATIC ) {
                return;
            }
            if ( field == _cancelButton ) {
                _returnCode = -1;
                close();
            } else
            if ( field == _okButton ) {
                if ( _questionField != null ) {
                    // Make sure there is some data entered
                    String temp = _questionField.getText();
                    if ( temp == null || temp.length() < 1 ) {
                        Status.show("Input required, please update \"" + _questionField.getLabel() + "\"");
                        _questionField.setFocus();
                        return;
                    }
                }
                _returnCode = 0;
                close();
            }
        }
    
    }
    
  • regarding buttonField

    Hello

    I had added the

    ButtonField mySubmitButton = new ButtonField ("Accept");

    Add (mySubmitButton);

    Accept button appears on the screen.

    So how do the codes by pressing the button I accept.

    I want to make is that, when the user press the button accept, is true of the other class and msg comes "installation of an application.

    II has the study which FieldChangeListener is used, but no not a single idea to use it for acceptance of the buttonField

    Thank you and best regards

    Antoine SIngh

    You must create a class that extends to fieldChangelistener, then for your button to accept, you can use following code

    mySubmitButton.setChangeListener();
    

    in your fieldChanged method, you will need to write code that illustrates the other screen.

  • ButtonField label displays ".." rather than the text of the label

    I have a button that created the label 'OK' on the ground, however, when it displays it shows "..."   My code is below:

      _btnOK = new ButtonField("OK",  ButtonField.CONSUME_CLICK | ButtonField.NEVER_DIRTY );
             _btnOK.setChangeListener(new FieldChangeListener() {
                public void fieldChanged(Field field, int context)
                {
                    if (!_txtfilename.getText().equals("")) {
                        buildPath();
                        int lastSlash = _currentPath.lastIndexOf('/');
                        if (lastSlash == -1)
                        {
                            _currentPath += _txtfilename.toString();
                        }
                        else
                        {
                            _currentPath = _currentPath.substring(0, lastSlash + 1);
                            _currentPath += _txtfilename.toString();
                        }
                        createresultfile(_currentPath);
                    }
                    else {
                        _currentPath = null;
                    }
                    close_dialog();
                }
            });
    
             HorizontalFieldManager hfm = new HorizontalFieldManager()
             {
    
                 public void sublayout(int width, int height) {
                     int xpos = 0;
                     int ypos = 0;
                     int widfield1 = (int) (width * .8);
                     int widfield2 = (int) (width * .2);
                     int hieghthfm = 40;
                     Field field = getField(0);
    
                     setPositionChild(field, xpos, ypos+5);
                     layoutChild(field, widfield1, (int) (hieghthfm * .80));
    
                     Field field1 = getField(1);
    
                     setPositionChild(field1, xpos+widfield1, ypos);
                     layoutChild(field1, widfield2, widfield2);
                     setPosition(width, hieghthfm);
                     setExtent(width, widfield2);
             }
            };
             hfm.add(_txtfilename);
             hfm.add(_btnOK);
             dfm.addCustomField(hfm);
    
            _olf = new ObjectListField();
            dfm.addCustomField(_olf);
            updateList(path);
            _txtfilename.setFocus();
    

    Any help would be appreciated.

    One thing I would do it immediately to make changes in your code, regardless of anything else - hfm one Manager: substitute you fully sublayout, so you don't need to extend HFM. Implement your own getPreferredWidth and getPreferredHeight to be on the safe side and you've got yourself a personalized presentation of fine Manager.

    You have a typo in your setExtent fault - it should probably be setExtent (width, hieghthfm). Your setPosition also made a lot of sense - decide what you really want to be there. It defines the X, Y of the upper left corner of your manager. I'm not sure that you need-your DialogFieldManager should take care of this.

    Finally - check how much width you spend in your layoutChild (Field1,...)-your widfield2 might be too small so that it shows something significant. Don't forget no-ButtonField has its own, relatively complex, on the page, including some padding around the text.

  • 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.

  • FieldChangeListener - should work, but it is not

    public class TestDynamicMenus extends MainScreen implements FieldChangeListener {
        ButtonField btOK;
        public TestDynamicMenus () {
            ButtonField btOK = new ButtonField ("OK", ButtonField.CONSUME_CLICK);
            btOK.setChangeListener(this);
            add(btOK);
        }
    
        public void fieldChanged(Field field, int context) {
            if (field == btOK){
                Dialog.inform("Hi");
                }
        }
    }
    

    It drives me crazy - button shows in the Simulator, but nothing happens when I push it. What I am doing wrong?

    Hello

    Just change:

    ButtonField btOK = new ButtonField ('OK', ButtonField.CONSUME_CLICK);

    TO

    btOK = new ButtonField ('OK', ButtonField.CONSUME_CLICK);

  • fieldchangelistener

    When I put tell listener as objectchoicefieldlistener it works 5n...

    Lst FieldChangeListener = new FieldChangeListener() {}
    ' Public Sub fieldChanged (field field, int context) {}

    try {}
            
    If {(field instanceof field)
        
    ObjectChoiceField tt = field (ObjectChoiceField);
    String str = (String) tt.getChoice (tt.getSelectedIndex ());
    UiApplication.getUiApplication () .pushScreen (new prac (str));
       
    }
        
    }
    {} catch (ClassCastException (e)
    e.printStackTrace ();
    }
      
    }
    };

    I select an option frm objectchoicefield n control jumps 2 form d n poster select next value...

    but when I implement say same listener for buttonfield instead of objectchoicefield for control of tht jumps 2 next screen aftr I click the button... It work... n y?

    Hello

    try using the following code

    public void fieldChanged(Field field, int context) { if(field == bn)   {      String str =(String)choicefiled.getChoice(choicefiled.getSelectedIndex());            UiApplication.getUiApplication().pushScreen(new prac(str));           }
    
           }
    
  • Problem with the automatic opening by ButtonField menu

    Hello guys I have a problem.

    I wrote this simple program to move from one screen to another screen

    The problem is that when I press the button (to switch to another screen) on the next screen automatically opens the menu.

    WHY?

    Thanks for any answers

    Net.rim.device.api.ui import. *;
    Net.rim.device.api.ui.component import. *;
    Net.rim.device.api.ui.container import. *;

    SerializableAttribute public class DisplayChange extends UiApplication implements
    {FieldChangeListener}
    secondScreen of screen private;
    private screen firstScreen;
    Private ButtonField back,
        
    Public Shared Sub main (String [] args) {}
    PAP DisplayChange = new DisplayChange ();
    theApp.enterEventDispatcher ();
    }

    public DisplayChange() {}
    secondScreen = new MainScreen();
            
    back = new ButtonField ("back", ButtonField.FIELD_LEFT);
    back.setChangeListener (this);
    secondScreen.add (back);

    firstScreen = new MainScreen();
    firstScreen.setTitle ("Primo screen");

    firstScreen.add (new LabelField ("WELCOME\n"));

    go = new ButtonField ("Go", ButtonField.FIELD_HCENTER);
    go.setChangeListener (this);
    firstScreen.add (GB);
    pushScreen (firstScreen);

    }
    ' Public Sub fieldChanged (field field, int context)
    {
    if(Field == Go) {}
    pushScreen (secondScreen);
    }

    of other if(field == back) {}
    popScreen (secondScreen);

    }

    }

    }

    Add the CONSUME_CLICK style to your buttonfield

  • How to disable the default action with ButtonField

    Hello

    Here's what I get "my custom action" when you click on a button:

    FieldChangeListener listener = new FieldChangeListener() {}
    ' Public Sub fieldChanged (field field, int context) {}
    my custom action
    };
    };
    ButtonField myButtonField = new ButtonField ("Test button");
    Add (myButtonField);
    myButtonField.setChangeListener (listener);

    But when I click on the button shows a list of 3-point default choice. How can I disbale this list?

    Thank you.

    Something like that...

    ButtonField myButtonField = new ButtonField (button "Test", ButtonField.CONSUME_CLICK);

  • Menu is displayed when you click buttonfield

    Hello

    in my application, I have a few fields button.

    For each one, I put a changeListene in order to perform actions when the button is pressed:

    ButtonField button = new ButtonField ("button");
    button.setChangeListener (new FieldChangeListener() {}
    ' Public Sub fieldChanged (field field, int context) {}
    my implementation
    }
    });

    Evetything goes very well with jre 6.0, but with 4.6, 4.7 and 5.0 jre whenever I click the button, the menu dialog box appears.

    How can I avoid this?

    Thank you

    use the CONSUME_CLICK style

Maybe you are looking for

  • Partition Time Capsule to back up 2 computers?

    Can I partition a Time Capsule to save 2 wireless computers using Time Machine?

  • Mac programs show recent "bad" items

    First of all, thank you for reading my question! I have difficulties to access the "recent items" when right click on native Mac programs (for example, a clip, Pages, Quicktime, etc.). The programs demonstrate quite recent items, but these "recent it

  • Scope of voltage zero

    Hello world I'm new to labview. I use a high precision load cell and signal conditioner that provide precise and exit excitation (10 V) The problem when I use the DAQ (myDAQ) card to measure the output voltage The tension reaches zero to time finishe

  • Update Installation Glich

    I just downloaded an upgrade to vista service pack (automatic?), but something was wrong during the process. After step 3, my computer has restarted but just said that it was installing new stage 3. I tried to turn off my computer, but when I turn it

  • pointer is not displayed for Microsoft Laser mouse 7000

    Original title: Microsoft Laser mouse 7000... pointer is not displayed? Mouse Microsoft Laser 7000 used on HP laptop. Pointer icon has disappeared from the overnight! What is a computer or mouse problem? How can I fix it? DWH