[英]How can I query a specific column value in a Parse.com class and set it to a string?
How can I query the specific value of an object in my Parse class and set it to a String? 如何在我的Parse类中查询对象的特定值并将其设置为String? Given that I have an object with a specific objectId, I want the value for the "position" column, and I want to set it to a String.
假设我有一个带有特定objectId的对象,则需要“ position”列的值,并将其设置为String。
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("NativeAd");
query.whereEqualTo("objectId", "fYBeufqdOt");
query.findInBackground(new FindCallback() {
@Override
public void done(List objects, ParseException e) {
if (e == null) {
Log.d("NativeAd", "Retrieved " + objects.size());
for (ParseObject adPosition : objects) {
String n = adPosition.get("position").toString();
System.out.println(n);
}
} else {
Log.d("NativeAd", "Error: " + e.getMessage());
}
}
});
i think this will work 我认为这会工作
@Override
public int getViewType(int position) {
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("NativeAd");
query.whereEqualTo("objectId", "fYBeufqdOt");
final String[] n = new String[1];
query.getFirstInBackground(new GetCallback() {
@Override
public void done(ParseObject object, ParseException e) {
n[0] = object.toString();
}
});
int viewType = VIEW_TYPE_MARKET_FEED;
if ((position % n[0] == 0) && position > 0) {
viewType = VIEW_TYPE_AD;
}
return viewType;
} }
Now answers to your questions : n was declared in GetCallback anonymous class hence n has scope for that class only. 现在回答您的问题:n在GetCallback匿名类中声明,因此n仅适用于该类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.