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