I'm having some trouble setting the FieldChangeListener of a new button I am creating after an action is performed. I have a list of ButtonFields and when I create a new VoiceNote a new ButtonField linking to that VoiceNote is added.
I create a new voice note to be edited in another screen and when that screen is closed the note is added to my database and the new button is added to the list. The button is added correctly but when I click on it, it does nothing.
The code of the MenuItem that invokes this is as follows:
private final class NewNote extends MenuItem
{
Vector _voiceNotes;
ListStyleButtonField _nuevoBoton;
public NewNote(Vector voiceNotes)
{
super("New Voice Note",0,0);
_voiceNotes = voiceNotes;
}
public void run() {
VoiceNote newNote = new VoiceNote("", "", null);
UiApplication.getUiApplication().pushModalScreen(new RecordScreen(_managerBD, newNote));
if(newNote.get_id() != -1)
{
_voiceNotes.addElement(newNote);
_nuevoBoton = new ListStyleButtonField(newNote.get_nombre(), 0);
add(_nuevoBoton);
newNote.set_noteIndex(_nuevoBoton.getIndex());
UiApplication.getUiApplication().invokeAndWait(new Runnable() {
public void run() {
_nuevoBoton.setChangeListener(UiApplication.getUiApplication().getActiveScreen().getChangeListener());
}
});
UiApplication.getUiApplication().relayout();
}
}
}