如何一次在imageview中显示单个图像?

时间:2016-01-04 10:45:29

标签: android mysql

在MYSQL数据库中,我通过用逗号分隔将多个图像存储在一个字段中。

在我的Android应用程序中,我必须一次只显示单个图像或第一个图像。

如何从我的代码中获取并存储数据库中的所有图像,这些图像由逗号分隔并且一次只显示一个?

3 个答案:

答案 0 :(得分:0)

您可以使用逗号获取所有图像。在Array中用逗号分割字符串之后,用Java,List of String

添加逻辑

答案 1 :(得分:0)

Fetch all the image path from db into an arraylist/array by splitting your comma separated string and then loop through that arraylist/array to show your images one at a time. To create that arraylist create a position variable and update that position variable with the index of comma and then find substring using that index

答案 2 :(得分:0)

您可以通过将字符串拆分为','

来获取单个图片网址
String[] images = imageStringFromDB.split(",");

images数组包含所有图像路径。您可以通过创建AsyncTask从URL下载Bitmap来加载ImageView中的任何元素。