Parse.com ParseQuery从ParseQuery中检索图像并获取第一个Object

时间:2016-03-02 22:11:09

标签: java android parse-platform

如何获取Parse查询的第一行Object。然后我会将其显示为ImageView。

ParseQuery query = new ParseQuery("Collection");
    query.getInBackground("AN_OBJECT_ID_HERE",new GetCallback() {
        public void done(ParseObject object, ParseException e) {
            if (object == null) {
                Log.d("test", "The object was not found...");
            } else {
                Log.d("test", "Retrieved the object.");
                ParseFile fileObject = (ParseFile)object.get("images");
                fileObject.getDataInBackground(new GetDataCallback() {
                    public void done(byte[] data, ParseException e) {
                        if (e == null) {
                            Log.d("test", "We've got data in data.");
                            // use data for something

                        } else {
                            Log.d("test", "There was a problem downloading the data.");
                        }
                    }
                });
            }
        }
    });

提前谢谢

1 个答案:

答案 0 :(得分:0)

您可以在以下示例中找到一些帮助:

完整代码:https://github.com/mevansjr/FSO/blob/master/MDF%203/Week%204/AddFriend/src/com/markevansjr/addfriend/AddFriend.java#L48

    ParseQuery query = new ParseQuery("ContactObject");
    query.findInBackground(new FindCallback() {
        @SuppressWarnings("unchecked")
        public void done(List<ParseObject> objects, ParseException e) {
            if (e == null) {

                if (objects.toArray().length > 0){
                    _data = new ArrayList<Map<String, String>>();

                    for(int ii=0;ii<objects.toArray().length;ii++){                         
                        ParseObject s = objects.get(ii);
                        Map<String, String> map = new HashMap<String, String>(2);
                        map.put("fname", s.getString("fname"));
                        map.put("lname", s.getString("lname"));
                        map.put("phone", s.getString("phone"));
                        map.put("email", s.getString("email"));
                        map.put("id", s.getObjectId());
                        map.put("fullname", s.getString("fname")+" "+s.getString("lname"));
                        _data.add(map);
                    }