我正在尝试加载存储在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。当我运行应用程序时,图像不会出现。
答案 0 :(得分:2)
这就是我通常得到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);