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. 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
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
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.