There's multiple ways to do this. For example, if you have an EditField
instance like this:
private EditField _editField;
then you can subclass EditField
and override the keyChar()
method:
_editField = new EditField() {
protected boolean keyChar(char key, int status, int time) {
super.keyChar(key, status, time);
// 'key' is the most recent entered char
}
});
or, you can implement a FieldChangeListener
and listen for changes:
_editField.setChangeListener(new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
String text = _editField.getText();
// 'text' is the full text contents of the EditField
}
});