2016-05-19 67 views
0

我在ParseClass中創建了一個指針我想從指針查詢添加我創建了ParseObject類,因此如何設置ParseObject來查詢指針。如何從解析中的指針查詢

遊戲解析類有指針「位置」

@ParseClassName("Games") 
public class Offers extends ParseObject{ 

     public String getPlaceName() { 
      return getString(getParseObject("Places").getString("PlaceName")); 
     } 
+0

其粘性第一次嘗試它的parseObject和存儲它直接指向 –

+0

@HardikParmar如何去掉它可以寫下代碼? –

+0

我有帖子ans –

回答

-1

如果你想獲得遊戲與有關地方的數據對象,則應在查詢中使用「包括」。

ParseQuery<Offers> query = ParseQuery.getQuery(Offers.class); 
//query.equalTo("objectId", "gameId"); 
query.include("Places"); 
query.getFirstInBackground(new GetCallback<Offers>() { 
    @Override 
    public void done(Offers obj, ParseException e) { 
     if(e!=null) { 
      Log.e("err", e.getMessage()); 
     } 
     else { 
      Log.d("PlaceName", obj.getParseObject("Places").getString("PlaceName")); 
     } 
    } 
}); 

如果你想通過指針來獲取相關的數據(的parseObject只包含ID)

  ParseObject place = ParseObject.createWithoutData("Places","id"); 
      place.fetchInBackground(new GetCallback<ParseObject>() { 
       @Override 
       public void done(ParseObject object, ParseException e) { 
        //do what you want 
       } 
      }); 
-1

 final ArrayList<ParseObject> Places = new ArrayList<ParseObject>(); 

    ParseQuery<ParseObject> offer = new ParseQuery<ParseObject>("className"); 

    offer.findInBackground(new FindCallback<ParseObject>() { 

     @Override 
     public void done(List<ParseObject> objects, ParseException e) { 
      // TODO Auto-generated method stub 
      if (e == null) { 
       // success 
       for (ParseObject parseObject : objects) { 
        Places.add(parseObject.getParseObject("Places")); 
       } 

       Log.e("TAG ", "get parse pointer object " + Places.size()); 
      } else { 
       // fail 
      } 
     } 
    });