Here is a simple example of how to listen to the change event.
This functionality replaces the deprecated listBox.addChangeListener(new ChangeListener(){//implementation} );
private ListBox populateLearningLanguage()
{
final ListBox listBox = new ListBox();
addLanguages(listBox);
listBox.setSelectedIndex(2);
listBox.addChangeHandler(new ChangeHandler()
{
public void onChange(ChangeEvent event)
{
int selectedIndex = listBox.getSelectedIndex();
if (selectedIndex > 0)
Window.alert("Something got selected " + listBox.getValue(selectedIndex));
}
});
return listBox;
}
I think your if-statement should be:
ReplyDeleteif (selectedIndex>-1) ..
Hi Willem,
ReplyDeletethank you for the correction, yes you are right if the first item is a valid selection and not "please select .."
This is helpfull to me
ReplyDelete