无法从内部类访问。安卓

时间:2015-11-28 06:43:13

标签: android parse-platform

findInBackground

成功后无法返回总和
public class Chew_Count_Graph_morning extends Activity {    

float lc, rc;

public float countvalue(int month, int day) {
    ParseQuery<ParseObject> query = ParseQuery.getQuery("Data");
    query.whereEqualTo("username", mychild);
    query.whereEqualTo("MorningNoonEvening", "morning");
    query.whereEqualTo("Month", month);
    query.whereEqualTo("Day", day);
    query.findInBackground(new FindCallback<ParseObject>() {
        public void done(List<ParseObject> data, ParseException e) {
            if (data.isEmpty() == false) {
                lc = data.get(0).getInt("LeftChew"); //lc = 50
                rc = data.get(0).getInt("RightChew"); //rc = 100
             Log.d("the inner value is ", " " +(lc+rc));//inner value is 150
            } else {
                lc = 0;
                rc = 0;
            }
        }
    });
    Log.d("return ", " " +(lc+rc)); // return : 0
    return lc+rc;
}
}

如何获得返回值150(即lc + rc)?

1 个答案:

答案 0 :(得分:0)

此处更正了代码:

public class Chew_Count_Graph_morning extends Activity {

float lc, rc;

public float countvalue(int month, int day) {
ParseQuery<ParseObject> query = ParseQuery.getQuery("Data");
query.whereEqualTo("username", mychild);
query.whereEqualTo("MorningNoonEvening", "morning");
query.whereEqualTo("Month", month);
query.whereEqualTo("Day", day);
query.findInBackground(day, new GetCallback<ParseObject>() {
    public void done(ParseObject data, ParseException e) {
        if (data.isEmpty() == false) {
            lc = data.get(0).getInt("LeftChew"); //lc = 50
            rc = data.get(0).getInt("RightChew"); //rc = 100
         Log.d("the inner value is ", " " +(lc+rc));//inner value is 150
        } else {
            lc = 0;
            rc = 0;
        }
    }
});

Log.d("return ", " " +(lc+rc)); // return : 0
return lc+rc;
}
}

它宣布全球,因此无需宣布为最终