如何从Parse DataBrowser中检索ParseObject

时间:2014-03-10 17:10:06

标签: android parsing

我有这个代码:我在“NameCurrentStudent”中检索某个学生的课程,然后将这些课程存入一个ArrayList

ParseQuery<ParseObject> query = ParseQuery.getQuery("Courses");
    query = query.whereEqualTo("Student", NameCurrentStudent);
    query.findInBackground(new FindCallback<ParseObject>() {

        @Override
        public void done(List<ParseObject> courseList, ParseException e) 
        {
            if (e == null) 
            {
                courses.clear();
                for (ParseObject course : courseList) 
                {
                    courses.add(course.getString("NameCourse"));
                }
            } 
            else 
            {
                Log.d("Post retrieval", "Error: " + e.getMessage());
            }
        }
    });

但是当我使用debug时,skipps query.findInBackground(new FindCallback(){ 有谁知道为什么?

1 个答案:

答案 0 :(得分:2)

ParseQuery<ParseObject> queryP = ParseQuery.getQuery("Courses");
    queryP.whereEqualTo("Student", nameStudent);
    queryP.findInBackground(new FindCallback<ParseObject>() {
        @Override
        public void done(List<ParseObject> coursesList, ParseException e) 
        {
            ArrayList<String> courses = null;
            if (e == null) 
            {
                courses = new ArrayList<String>();
                for (ParseObject course : coursesList) 
                {
                    String courseName = course.getString("CoursesNameInParseColumn");       
                    courses.add(courseName);
                }
            } 
            else 
            {
                Log.d("Post retrieval", "Error: " + e.getMessage());
            }

            populateCoursesList(courses);
        }
    });