Android:从解析文件加载图像视图 [英] Android : load an imageview from a Parsefile
本文介绍了Android:从解析文件加载图像视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试通过"objectId "找到一个 ParseObject,然后检索图像"ImageFile ",然后将其加载到 imageview,它不起作用,我正在获取 USER 字符串,你能帮我吗有了这个,当我使用另一个查询时它会起作用:query.find()
I'm trying to find a ParseObject by " objectId ", then retrieve the image " ImageFile " and then Load it to the imageview, it doesn't work and i'm getting the USER String, can you help me out with this, it works when i use another query like : 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中显示图片的代码:
The code for displaying image in 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
这篇关于Android:从解析文件加载图像视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文