@xbs7

Как вставить картинку ссылкой в ListCell?

Приветствую. Нужна помощь с listview, точнее с listcell. Нужно в new ImageView(imagery.getText()) вставить ссылку. Через переменную imagery в updateItem не получается. Выбивает ошибку URL must not be empty. Если создавать переменную типа стринг и присвоить ей ссылку внутри CustomListCell() или даже где объявляются вообще все переменные, то работает, а если подать ее извне, то говорит что переменная пустая. Хотя в updateItem системаутом показывает значение переменной(саму ссылку). Не совсем понимаю что делать.
spoiler
public 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);
        }
    }}
  • Вопрос задан
  • 32 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
Bell Integrator Ульяновск
До 400 000 ₽
Bell Integrator Хабаровск
До 400 000 ₽
Bell Integrator Ижевск
До 400 000 ₽
18 апр. 2024, в 21:56
2000 руб./за проект
18 апр. 2024, в 21:00
150 руб./за проект