Sometimes, we need to maintain a particular format in EditField e.g. maintaining a phone number format while user is giving the input. In such condition, it is necessary to keep track of what user is typing. This tip will help you to keep tracking the user input.
Take a BasicEditField:
Now, add this mEditField to the screen :
mEditField = new BasicEditField(USE_ALL_WIDTH);
mEditField.setBorder(BorderFactory.createSimpleBorder(new XYEdges(1, 1, 1, 1)));
mEditField.setChangeListener(this); // it is necessary
add(new LabelField("Type here Something and we will track you..."));
Along with this, you need to override the method fieldChanged(Field field, int arg1) of class FieldChangeListener as following :
public void fieldChanged(Field field, int arg1)
if(field == mEditField)
Dialog.alert("You typed " + mEditField.getText());
The work is done. Now you will get a dialog alert as you will type something on the EditField. You can handle user input according to your wish and can do a lot of interesting things with the EditField.