Reusing same ImageView multiple times in the same scene on JavaFX

后端 未结 3 811
栀梦
栀梦 2021-01-20 19:28

I\'m trying to build a Twitter-style ListView, and I couldn\'t reuse the same ImageView multiple times in the same list. Loading multiple copies seem to be wasteful and caus

3条回答
  •  不思量自难忘°
    2021-01-20 20:15

    Caching images is good way.

    Also You can load images in background, it greatly improve performance.

    public Image getImage(String path, boolean backload) {
       image = imageCache.get(path);
       if (image == null) {
          image = new Image(path, backload);
          imageCache.put(path, image);
       }
       return image;
    }
    

提交回复
热议问题