gpt4 book ai didi

安卓 : load an imageview from a Parsefile

转载 作者:行者123 更新时间:2023-11-29 15:13:27 25 4
gpt4 key购买 nike

我试图通过“objectId”找到一个 ParseObject,然后检索图像“ImageFile”,然后将其加载到 imageview,它不起作用,我正在获取 USER 字符串,你能帮帮我吗有了这个,当我使用另一个查询时它可以工作:query.find()

      ParseImageView mealImage = (ParseImageView) findViewById(R.id.icon);

ParseQuery<ParseObject> query1 = ParseQuery.getQuery("Annonces");


query1.getInBackground("ux3Af0cwEx", new GetCallback<ParseObject>() {
public void done(ParseObject Annonces, ParseException e) {


photoFile = (ParseFile) Annonces.get("ImageFile");
text1.setText((CharSequence) Annonces.get("USER"));

}
});
mealImage.setParseFile(photoFile);
mealImage.loadInBackground(new GetDataCallback() {
@Override
public void done(byte[] data, ParseException e) {

}
});

}

最佳答案

在imageview中显示图片的代码:

ParseFile image = (ParseFile) userData.getParseFile("user_image");

然后调用下面的函数。

loadImages( photoFile, mealImage);

private void loadImages(ParseFile thumbnail, final ImageView img) {

if (thumbnail != null) {
thumbnail.getDataInBackground(new GetDataCallback() {
@Override
public void done(byte[] data, ParseException e) {
if (e == null) {
Bitmap bmp = BitmapFactory.decodeByteArray(data, 0, data.length);
img.setImageBitmap(bmp);
} else {
}
}
});
} else {
img.setImageResource(R.drawable.menu);
}
}// load image

关于安卓 : load an imageview from a Parsefile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27682857/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com