0
所以這似乎並沒有工作,但然後再次無法從void方法返回一個字符串。問題是我絕對需要根據我的類的結構來返回一個字符串。我該怎麼做才能做到這一點?我需要獲得物品價格的價值。從Parse.com返回字符串查詢
@Override
public String getCost() {
final String[] productValue = {"null"};
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Inventory");
query.whereEqualTo("productName", "Capris");
query.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> list, ParseException e) {
if (e == null) { //no exception, hence success
for (ParseObject productCost : list) {
productValue[0] = (String) productCost.get("productPrice");
// Cannot return a value from a method with void result type
return productValue[0];
}
}
else {
// Cannot return a value from a method with void result type
return null;
}
}
});
return null;
}
權更換findInBackground。感謝您指出,但它仍然沒有解決的問題,我不能返回一個無效方法的字符串。無論哪種方式,我需要提取該字符串。我的getCost()方法必須返回一個String。 – santafebound
我在評論中發現我的錯誤。 – santafebound
讓我知道,如果它不起作用 – abhishesh