Приветствую. Нужна помощь с listview, точнее с listcell. Нужно в
new ImageView(imagery.getText()) вставить ссылку. Через переменную
imagery в
updateItem не получается. Выбивает ошибку
URL must not be empty. Если создавать переменную типа стринг и присвоить ей ссылку внутри
CustomListCell() или даже где объявляются вообще все переменные, то работает, а если подать ее извне, то говорит что переменная пустая. Хотя в
updateItem системаутом показывает значение переменной(саму ссылку). Не совсем понимаю что делать.
spoilerpublic class CustomListCell extends ListCell<CustomThing> {
private HBox content;
private Text name;
private Text price;
private Text comments;
private Text imagery;
public CustomListCell() {
super();
name = new Text();
price = new Text();
comments = new Text();
imagery = new Text();
VBox vBox = new VBox(name, price,comments);
content = new HBox(new ImageView(imagery.getText()),vBox);
content.setSpacing(10);
}
@Override
public void updateItem(CustomThing item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) { // <== test for null item and empty parameter
name.setText(item.getName());
price.setText(item.getPrice());
comments.setText(item.getComments());
imagery.setText(item.getImagery());
setGraphic(content);
} else {
setGraphic(null);
}
}}