【问题标题】:Getting Image from Parse/Android从 Parse/Android 获取图像
【发布时间】:2015-05-09 18:12:43
【问题描述】:

我正在尝试加载存储在 Parse 中的图像;使用本教程中的代码:https://parse.com/tutorials/mealspotting 我写了这段代码:

 mProfileImage = mCurrentUser.getParseFile("ProfilePhoto");


        mProfilePhoto = (ParseImageView) findViewById(R.id.meal_preview_image);




        mProfilePhoto.setParseFile(mProfileImage);
        mProfilePhoto.loadInBackground(new GetDataCallback() {
            @Override
            public void done(byte[] data, ParseException e) {
                mProfilePhoto.setVisibility(View.VISIBLE);
            }
        });

我的布局中有这个:

<com.parse.ParseImageView
        android:id="@+id/meal_preview_image"
        android:layout_width="wrap_content"
        android:layout_height="200dp" />

我正在使用这个 protected ParseImageView mProfilePhoto;,一个 ParseImageView。当我运行应用程序时,图像没有出现。

【问题讨论】:

  • 检查这个是否被添加到AndroidMenifest

标签: android parse-platform


【解决方案1】:

这就是我通常获取ImageUrl 并在ImageView 中显示它的方式,其中也包括图像缓存机制。你需要 parseObject。

String Imgurl;
ParseFile image = (ParseFile) parseObject.get("ProfilePhoto"); 
if (image!=null) {
   Log.d("track", image.getUrl());
   Imgurl = image.getUrl();
} 

然后使用一些像 Universal Image Loader 这样的图像缓存库来​​避免 OutOfMemory 异常和平滑滚动。

imageLoader.displayImage(Imgurl, imageView);

【讨论】:

  • 我收到一个错误:无法从静态上下文中引用静态 displayImage。我添加了通用图像加载器,然后执行此操作:stackoverflow.com/questions/17267671/… 是否调用了 imageLoader?
  • 你不需要创建类。访问 github 并输入 Universal Image Loader。将指导您如何安装和设置。
猜你喜欢
  • 1970-01-01
  • 2017-06-22
  • 2018-01-01
  • 1970-01-01
  • 2014-11-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-21
相关资源
最近更新 更多