简体   繁体   English

从ParseUser检索图像时遇到问题

[英]Having Problems in retrieving Images from ParseUser

I want to retrieve images from default User class from Parse.com. 我想从Parse.com的默认User类中检索图像。 I only want values from the column named "Image". 我只想要来自名为“ Image”的列中的值。

ParseUser currentuser = ParseUser.getCurrentUser();
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("following");
query.whereEqualTo("username", currentuser);

try {
    ob = query.find();
} catch (ParseException e) {
    e.printStackTrace();
}

"Image" is the column name. “图像”是列名。

for (ParseObject user : ob) {
    // Locate images in pic column
    image = (ParseFile) user.get("Image");
}

How can I apply a loop to get all image files in a list? 如何应用循环以获取列表中的所有图像文件?

image.getDataInBackground(new GetDataCallback() {
     public void done(byte[] data, ParseException e) {
         if (e == null) {
             Bitmap pictureBitMap = BitmapFactory.decodeByteArray(data, 0, data.length);

             img.setImageBitmap(pictureBitMap);

             listView.setAdapter(new myCustomList(MainActivity.this));
         } else {
             // something went wrong
         }
     } 
});

Consider using an open source library such as Universal Image Loader(UIL) so you wouldn't have to do the heavy lifting of downloading the file converting it to Bitmap and setting it to an imageView. 考虑使用诸如Universal Image Loader(UIL)之类的开源库,这样您就不必下载文件将其转换为Bitmap并将其设置为imageView了。

Basically you can retrieve the url from parseFile 基本上您可以从parseFile检索网址

String url = parseFile.getUrl();

And in UIL simply pass the url and the imageView 在UIL中只需传递url和imageView

imageLoader.displayImage(imageUri, imageView);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM