2015-09-28 36 views
0

我是個初學者,所以我不瞭解parse.com中的很多東西。 我有一個類照片擴展ParseObject,並在Parse.com中的表對象照片。 當我從照片查詢數據時,我有一個問題。 這是我的問題:來自Parse.com的查詢數據

java.lang.IllegalArgumentException: value may not be null. 

這是我的照片類:

@ParseClassName("photo") 
public class Photo extends ParseObject { 
public Photo() { 
} 
public void setPhoto(ParseFile photo){ 
    put("imageFile", photo);  ///value may not be null. 
} 
public ParseFile getPhoto() { 
    return getParseFile("imageFile"); 
} 
public void setName(String string){ 
    put("ImageName",string); 
} 
public String getName(){ 
    return getString("ImageName"); 
} 
} 

這是我的代碼:

final ArrayList<Photo> photos = new ArrayList<>(); 
      try { 
       ParseQuery<ParseObject> query1 = new ParseQuery<>("photo"); 
       query1.whereMatches("trade_id",idTrade); 
       list = query.find(); 
       for (ParseObject mPhoto : list) { 
        Photo newPhoto = new Photo(); 
        newPhoto.setPhoto((ParseFile) mPhoto.get("imageFile")); 
        photos.add(newPhoto); 
       } 
      } catch (com.parse.ParseException e) { 
       Log.e("Error", e.getMessage()); 
       e.printStackTrace(); 
      } 

和我的解析表中有2列:鏡像文件(文件)& trade_id(字符串) 告訴我如何解決它?請!

+0

?變量'query1','idTrade','list','mPhoto','newPhoto','photos'的值是否都有效? –

+0

他們沒問題,你看我的代碼中的評論///值可能不是null。 –

+0

你可以在解析時粘貼你的表格的屏幕截圖。你的錯誤陳述並不多。 – Naveed

回答

0

,你不應該在這行是異常拋出做

mPhoto.getParseFile("imageFile") 

代替

mPhoto.get("imageFile") 
+0

這不是問題:( 我對我的代碼發表了評論/////值不得爲空...... –