2014-02-20 31 views
0

使用解析SDK爲Android,我想接收來自查詢ParseUser,下面的代碼是我曾嘗試:從列表中獲取ParseUser <ParseUser>使用Parse SDK for android?

ParseQuery<ParseUser> query = ParseUser.getQuery(); 

Follow.include("author"); 
query.whereEqualTo("User", "Alex"); 
query.findInBackground(new FindCallback<ParseUser>() {  
public void done(List<ParseUser> objects, ParseException e) { 
if (e == null) { 
// This is where I want to receive the ParseUser from the List<ParseUser> 
ParseUser pu = objects.get("author"); 
} else { 

} 


} }); 

Object.get(「作家」)產生的錯誤。

三江源閱讀:)

回答

1
ParseUser pu = objects.get("author"); would be incorrect usage. Get method is generally used to get a object at a particular position in the list. 

查詢返回您已命名爲對象ParseUsers的列表。 現在使用迭代器遍歷列表以訪問每個ParseUser。

這樣

for(ParseUser pu : objects){ 
     //access the data associated with the ParseUser using the get method 
     //pu.getString("key") or pu.get("key") 
} 

希望這有助於!

相關問題