首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >动态图像滑块Android

动态图像滑块Android
EN

Stack Overflow用户
提问于 2016-06-30 03:45:09
回答 0查看 1.6K关注 0票数 0

我在我的应用程序中使用AndroidImageSlider库作为图像滑块。我正在使用如下所示的Hashmap加载图像:

代码语言:javascript
复制
HashMap<String,String> url_maps = new HashMap<String, String>();
url_maps.put("Image 1", "http://example.com/./project_image/example.jpg");
url_maps.put("Image 2", "http://example.com/./project_image/example.jpg");
url_maps.put("Image 3", "http://example.com/./project_image/example.jpg");


for(String name : url_maps.keySet()){
    TextSliderView textSliderView = new TextSliderView(this);
    // initialize a SliderLayout
    textSliderView
            .description(name)
            .image(url_maps.get(name))
            .setScaleType(BaseSliderView.ScaleType.Fit);

    //add your extra information
    textSliderView.bundle(new Bundle());
    textSliderView.getBundle()
            .putString("extra",name);

    mDemoSlider.addSlider(textSliderView);
}

注意:我将HashMap的键设置为每个图像的描述。

如何使此滑块动态化?

我想从json feed中动态加载图像,如下所示:

代码语言:javascript
复制
{
  "Images": [
    {
      "title": "title",
      "Image": "http://example.com/./project_image/example.jpg"
    },
    {
      "title": "Distribution",
      "Image": "http://example.com/./project_image/example.jpg"
    },
    {
      "title": "Distribution",
      "Image": "http://example.com/./project_image/example.jpg"
    }
  ]
}

我可以使用HashMap吗?或者我需要使用替代方案吗?如果是,请提出建议。或者我使用不同的库?如有,请提供参考资料。谢谢。

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38108777

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档