use of org.apache.pivot.wtk.ListButtonSelectionListener in project pivot by apache.
the class ListButtons method initialize.
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
listButton = (ListButton) namespace.get("listButton");
imageView = (ImageView) namespace.get("imageView");
listButton.getListButtonSelectionListeners().add(new ListButtonSelectionListener() {
@Override
public void selectedItemChanged(ListButton listButtonArgument, Object previousSelectedItem) {
Object selectedItem = listButtonArgument.getSelectedItem();
if (selectedItem != null) {
// Get the image URL for the selected item
Image image = Image.loadFromCache(ImageUtils.findByName("/org/apache/pivot/tutorials/" + selectedItem, "image"));
// Update the image
imageView.setImage(image);
}
}
});
listButton.setSelectedIndex(0);
}
Aggregations