Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 获取解析文件到ImageView_Java_Android_Parse Platform - Fatal编程技术网

Java 获取解析文件到ImageView

Java 获取解析文件到ImageView,java,android,parse-platform,Java,Android,Parse Platform,我想从parse到ImageView获取文件。我试图通过“getDataInBackgound”获取,但是当我调用这个方法时,UI被卡住了,我得到了最后一个图像 ParseFile image = tableParseObjects.getParseFile(PARSE_IMAGES); image.getDataInBackground(new GetDataCallback() { @Override

我想从parse到ImageView获取文件。我试图通过“getDataInBackgound”获取,但是当我调用这个方法时,UI被卡住了,我得到了最后一个图像

ParseFile image = tableParseObjects.getParseFile(PARSE_IMAGES);

                    image.getDataInBackground(new GetDataCallback() {

                        @Override
                        public void done(byte[] data, ParseException e) {
                            Bitmap bitpic = BitmapFactory.decodeByteArray(data, 0, data.length);
                            ByteArrayOutputStream stream = new ByteArrayOutputStream();
                            bitpic.compress(Bitmap.CompressFormat.PNG, 100, stream);
                            vectorSample.setPic(bitpic);

                        }
                    });

我认为您必须使用或ImageLoader类加载图像。我也有同样的疑问,我也使用了ParseImageView。这是我的代码:

使用异步任务从parse.com检索ParseFile(图像):

public class BackgroundQuery extends AsyncTask<Object, Void, Object> {
    private String id;

    public BackgroundQuery(String id) {
        this.id = id;
    }

    @Override
    protected Object doInBackground(Object... params) {
        Object o = null;
        try {
            ParseQuery<ParseObject> query = ParseQuery.getQuery(params[0]
                    .getClass().getSimpleName());
            query.whereEqualTo("objectId", id);
            List<ParseObject> result = query.find();

            if (result != null) {
                for (ParseObject obj : result) {
                    o = obj.getParseFile("photo"); // Photo is the ParseFile
                }
            }
        } catch (ParseException e) {
            Log.e(TAG, e.getMessage());
        }
        return o;
    }
}
公共类后台查询扩展异步任务{
私有字符串id;
公共背景查询(字符串id){
this.id=id;
}
@凌驾
受保护对象doInBackground(对象…参数){
对象o=null;
试一试{
ParseQuery=ParseQuery.getQuery(参数[0]
.getClass().getSimpleName());
查询:whereEqualTo(“objectId”,id);
List result=query.find();
如果(结果!=null){
for(ParseObject对象:结果){
o=obj.getParseFile(“photo”);//photo是解析文件
}
}
}捕获(解析异常){
Log.e(标记,e.getMessage());
}
返回o;
}
}
在布局中,将其用作图像视图:

<com.parse.ParseImageView
        android:id="@id/imgv"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:adjustViewBounds="true />