Android - Parse.com从一个元素填充数组

时间:2015-07-08 01:33:38

标签: android arrays parse-platform

我正在尝试从parse.com查询中填充一个数组,并且我从查询中获取元素的部分存货。基本上我不知道在哪里获取exercise_object.get(location)的当前位置谢谢。

    ParseQuery<ParseObject> query = ParseQuery.getQuery("Programs");
    query.whereEqualTo("name", objname);
    query.orderByAscending("name");
    query.findInBackground(new FindCallback<ParseObject>() {
        @Override
        public void done(List<ParseObject> list, ParseException e) {
            if (e == null) {
                //success
                String [] exercice = new String[3];
                exercise_object = list;
                Toast.makeText(Wko_Display.this, "Workouts", Toast.LENGTH_LONG).show();
                ParseObject program_object = exercise_object.get(location);
                exercice [0] = exercise_object.getString("wk0");
                exercice [1] = exercise_object.getString("wk1");
                exercice [2] = exercise_object.getString("wk2");


            } 

1 个答案:

答案 0 :(得分:1)

如果我理解你正在尝试做的事情,那么这应该有效:

@Override
public void done(List<ParseObject> list, ParseException e){
    if (e == null){
        for (ParseObject pObj : list){
            String[] exercise = new String[3];
            // assuming each ParseObject has a pointer to a Program object in the database
            ParseObject programObject = pObj.getParseObject("location");
            // do whatever you want with this programObject

            // then do any further stuff with the current pObj in the list
            exercise[0] = pObj.getString("wk0");
            // ...

        }
    } else{
        Log.e(TAG, e.getMessage()); 
    }
}

如果你期望只从查询中返回一个对象,那将是错误的。让我知道。