0
A
回答
0
你可以使用这个库的图像加载到一个滑块:https://github.com/daimajia/AndroidImageSlider
在您的布局:
<com.daimajia.slider.library.SliderLayout
android:id="@+id/slider"
android:layout_width="match_parent"
android:layout_height="200dp"
/>
然后输入:
mDemoSlider = (SliderLayout)findViewById(R.id.slider);
HashMap<String,String> url_maps = new HashMap<String, String>();
url_maps.put("Hannibal", "http://static2.hypable.com/wp-content/uploads/2013/12/hannibal-season-2-release-date.jpg");
url_maps.put("Big Bang Theory", "http://tvfiles.alphacoders.com/100/hdclearart-10.png");
url_maps.put("House of Cards", "http://cdn3.nflximg.net/images/3093/2043093.jpg");
url_maps.put("Game of Thrones", "http://images.boomsbeat.com/data/images/full/19640/game-of-thrones-season-4-jpg.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)
.setOnSliderClickListener(this);
//add your extra information
textSliderView.bundle(new Bundle());
textSliderView.getBundle()
.putString("extra",name);
mDemoSlider.addSlider(textSliderView);
}
mDemoSlider.setPresetTransformer(SliderLayout.Transformer.Accordion);
mDemoSlider.setPresetIndicator(SliderLayout.PresetIndicators.Center_Bottom);
mDemoSlider.setCustomAnimation(new DescriptionAnimation());
mDemoSlider.setDuration(4000);
mDemoSlider.addOnPageChangeListener(this);
ListView l = (ListView)findViewById(R.id.transformers);
l.setAdapter(new TransformerAdapter(this));
l.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
mDemoSlider.setPresetTransformer(((TextView) view).getText().toString());
Toast.makeText(MainActivity.this, ((TextView) view).getText().toString(), Toast.LENGTH_SHORT).show();
}
});
1
中的AsyncTask的doInBackground试试这个()方法
InputStream in = new URL(IMAGE_URL).openStream();
Bitmap bmp = BitmapFactory.decodeStream(in);
和onPostExecute()方法将它设置为图像视图
imageView.setImageBitmap(bmp);
OR试试这个:
private Bitmap bmp;
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
try {
InputStream in = new URL(IMAGE_URL).openStream();
bmp = BitmapFactory.decodeStream(in);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
if (bmp != null)
imageView.setImageBitmap(bmp);
}
}.execute();
+0
谢谢你们工作良好 –
相关问题
- 1. 我需要旋转图像
- 2. Android图像滑块
- 3. Css3滑块多个图像
- 4. 如何将滑块库转换为带有滑块图像和大拇指图像的PHP代码
- 5. 我想让像滚动图像的图像滑块?
- 6. 将.png图像转换为.gif图像
- 7. 将图像转换为灰度图像
- 8. 将PIL图像转换为VIPS图像
- 9. Android图像滑动图像
- 10. 如何将网址转换成图像?
- 11. 转换所有图像为RGB传输
- 12. 我可以将awt图像转换为gwt图像吗?
- 13. 我想创建一个图像滑块滑动全自动文件夹中的所有相似的图像
- 14. 用carouFredSel构建具有此要求的图像滑块?
- 15. Android:带有许多图像的图库 - 如何根据需要下载图像?
- 16. Android图像滑块变焦
- 17. 图像滑块转换时间
- 18. 我需要我的图像在图像更改后保留
- 19. 图像识别将图像转换为android中的文本
- 20. 将图像解析为多个图像
- 21. 为什么我的图像滑块上有白色页面?
- 22. Java图像库 - 将网格图像转换为数组
- 23. 将图像转换为base64,同时从其他网址获取图像
- 24. 我想搜索所有的图像网址从SD卡
- 25. HTML有文字是正确的图像与图像滑块
- 26. 图像滑块:背部图像
- 27. android图像转换
- 28. webgl图像滑块
- 29. Jumbotron图像滑块
- 30. 全图像滑块
真好!现在我们该如何帮助你?请将此添加到您的问题中。 – Olayinka
试着在你身边实施...有很多可用的例子,执行它们......并且比你在遇到任何问题之前都不让我们知道SO –
请发布你试过的东西 – Massimo