我想将每个点击按钮的当前用户附加到类型列表的列中,以便稍后我可以得到有多少人按下它的长度。
这是我的代码:
public void findAnswered(CloudQuery query) throws CloudException {
query.findById(questionID, new CloudObjectCallback() {
@Override
public void done(CloudObject object, CloudException e) throws CloudException {
if (object != null) {
Log.i("---------FIND ANS QUERY", "SUCCESS I: " + object.getID());
answered(object);
}
if (e != null) {
Log.i("---------FIND ANS QUERY", "ERROR: " + e.getLocalizedMessage());
}
}
});
}
public void answered(CloudObject object) throws CloudException {
CloudObject [] user = {CloudUser.getcurrentUser()};
Log.i("------UPDATE ANS OBJECT", "A: " + this.answered);
Log.i("------UPDATE ANS OBJECT", "W: " + this.wrongAnswer);
Log.i("------UPDATE ANS OBJECT", "R: " + this.rightAnswer);
object.set("earnings", earnings);
object.set("dividend", dividend);
object.set("answered", user);
if (this.wrongAnswer == 1) {
object.set("wrong", user);
}
if (this.rightAnswer == 1) {
object.set("right", user);
}
object.save(new CloudObjectCallback() {
@Override
public void done(CloudObject object, CloudException e) throws CloudException {
if (object != null) {
// Success
Log.i("------UPDATE ANS OBJECT", "SUCCESS I: " + object.getId());
}
if (e != null) {
// Error
Log.i("------UPDATE ANS ERROR:", e.getLocalizedMessage());
}
}
});
}
但是当我尝试在两部手机上执行此操作时,它只会添加第一个单击它的用户并跳过第二个用户。如何继续将用户添加到同一个框?