我在我的应用程序中使用AndroidImageSlider库作为图像滑块。我正在使用如下所示的Hashmap加载图像:
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中动态加载图像,如下所示:
{
"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吗?或者我需要使用替代方案吗?如果是,请提出建议。或者我使用不同的库?如有,请提供参考资料。谢谢。
https://stackoverflow.com/questions/38108777
复制相似问题