【问题标题】:how to put array of download URLs of images to viewpager如何将图像的下载 URL 数组放入 viewpager
【发布时间】:2018-07-07 03:25:20
【问题描述】:

我制作了一个带有图像视图的视图寻呼机,我想使用视图寻呼机制作类似图像滑块的东西。我有一系列下载 URL。我怎样才能把这些网址打开图像到图像视图。我尝试搜索其他教程,但它们都使用位图。

【问题讨论】:

    标签: android arrays android-viewpager imageview firebase-storage


    【解决方案1】:

    使用全局数组存储 URL,然后使用 GLide Like 显示>>>

        @Override
        public Object instantiateItem(ViewGroup container, final int position) {
    
            layoutInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View view = layoutInflater.inflate(R.layout.image_fullscreen_preview, container, false);
    
            ImageView imageViewPreview = (ImageView) view.findViewById(R.id.image_preview);
    
            final ProgressBar pbLoad = view.findViewById(R.id.pbLoad);
    
            String image = images.get(position);
    
            imageViewPreview.setTag(image);
    
      Glide.with(getActivity()).load(image).thumbnail(0.5f).crossFade().diskCacheStrategy(DiskCacheStrategy.ALL).into(imageViewPreview);
    
    
    
            container.addView(view);
    
            return view;
        }
    

    【讨论】:

    • getActivity() 获取片段中的上下文。您通常可以使用 this 代替 that。
    猜你喜欢
    • 1970-01-01
    • 2017-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-25
    • 2019-12-24
    • 1970-01-01
    相关资源
    最近更新 更多