blackberryevent-handlingfocustextfieldblackberry-editfield

Automatically change focus among Editfields in Blackberry


I have five EditField objects in my BlackBerry app, each one will accept only one numeric character.

I want to change the focus from the first EditField to the second EditField when a character is entered. Note the focus from one to another EditField must go automatically and not by pressing Enter key or some other key.


Solution

  • You want to set a FieldChangeListener on the EditField to monitor when the contents of the field changes. Once the user has entered a single character you can move to the next field by calling Field.setFocus().