[英]how to set first image into imageView from ArrayList<string>
I am getting this array of images using Pix image picker library, I just want to display the first image from an array into image view.no idea how to do it. 我正在使用Pix图像选择器库获取此图像阵列,我只想将阵列中的第一张图像显示到图像视图中。 here is my code
这是我的代码
public void uploadImages(View view) {
Pix.start(Upload_ad.this,
100,
10);
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK && requestCode == 100) {
ArrayList<String> returnValue = data.getStringArrayListExtra(Pix.IMAGE_RESULTS);
for (String path: returnValue)
{
String base64 = getBase64FromFile(path);
encodedImageList.add(base64);
}
}
}
You can set base64 string from your encoded list as below 您可以从编码列表中设置base64字符串,如下所示
if (encodedImageList != null) {
byte[] decodedString = Base64.decode(encodedImageList.get(0), Base64.DEFAULT);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
yourimageview.setImageBitmap(decodedByte);
}
You can manage somehow by: 您可以通过以下方式进行管理:
ArrayList<String> returnValue = data.getStringArrayListExtra(Pix.IMAGE_RESULTS);
if(returnValue != null && !returnValue.isEmpty()) {
String firstImage = returnValue.get(0);
if(!TextUtils.isEmpty(firstImage)) {
// here you will find first-image
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.