简体   繁体   English

无法获取ParseObject值

[英]Can't get ParseObject values

Followed the online Parse docs to get the value but Android Studio won't recognize the getInt method & says - Cannot resolve method 'getInt(java.lang.String) 跟随在线Parse文档获取值,但Android Studio无法识别getInt方法并说- Cannot resolve method 'getInt(java.lang.String)

Shouldn't I be able to access the object inside the done callback? 我不应该能够在完成的回调中访问该对象吗? Currently the line is commented out because I can't build the project due to the error? 当前该行已被注释掉,因为由于错误我无法构建项目?

ParseQuery<ParseObject> query = ParseQuery.getQuery("Stats");
query.whereEqualTo("Name", rstr);
query.findInBackground(new FindCallback<ParseObject>() {
        public void done(List<ParseObject> stats, ParseException e) {

            if (e == null) {
                Log.d("score", "Retrieved " + stats.size() + " scores");
                //int score = stats.getInt("errors");
            } else {
                Log.d("score", "Error: " + e.getMessage());
            }
        }
    });

You need to fetch the ParseObject from the stats variable first, like below 您需要先从stats变量中获取ParseObject ,如下所示

ParseObject object = (ParseObject) stats.get(position);
int score = object.getInt("errors");

stats is not a ParseObject , it's a List<ParseObject> . stats不是ParseObject ,而是List<ParseObject> You need to get the objects out of the list. 您需要将对象从列表中删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM