2015-05-09 93 views
0

我正在尝试加载存储在分析中的图像;使用本教程中的代码:在我的布局从分析/ Android中获取图像

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); 
      } 
     }); 

我有这样的:https://parse.com/tutorials/mealspotting我写了这个代码

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

我用这protected ParseImageView mProfilePhoto;,一个ParseImageView。当我运行应用程序时,图像不会出现。

+0

检查,如果这是在AndroidMenifest加入<使用的许可机器人:名称= “android.permission.INTERNET对”/> <使用的许可机器人:名称= “android.permission.ACCESS_NETWORK_STATE”/> –

回答

2

这就是我通常如何获得ImageUrl并在ImageView中显示它,其中也包含图片缓存机制。你需要parseObject。

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

然后使用像通用图像加载器一些图像缓存库,以避免OutOfMemory异常和平滑滚动。

imageLoader.displayImage(Imgurl, imageView); 
+0

我我得到一个错误:没有静态displayImage不能从静态上下文中引用..我添加了通用图像加载程序,并遵循此:http://stackoverflow.com/questions/17267671/universal-imageloader-java-io-eofexception。 imageLoader叫什么? –

+0

你不需要创建类。访问github和类型的通用图像加载器。您将被引导如何安装和设置。 –