0
我要使用的數據我從getInBackground()
功能外解析得到但字段的值之外是null
檢索從解析數據,但不提供查詢
ParseQuery<ParseObject> query = ParseQuery.getQuery("Person");
query.getInBackground(invitedBy.getObjectId(), new GetCallback<ParseObject>() {
public void done(ParseObject object, ParseException e) {
if (e == null) {
// object will be your game score
//here the variables have an actual value
firstName = object.getString("firstName").toString();
lastName = object.getString("lastName").toString();
} else {
// something went wrong
}
}
});
//here the values for the firstName and lastName are null
invitorName.setText(firstName + " " + lastName);
任何建議如何解決這個問題。謝謝
大多數解析函數是異步運行的。這意味着他們開始了,並且您的應用程序可以同時進行。在發佈的代碼中,當執行達到setText時,getInBackground甚至還沒有開始。但getInBackground在完成時需要執行一個回調參數。在其中執行setText。 – danh 2015-03-30 22:30:44