奇怪的问题:
这段代码:
xNames[index] = String.valueOf(currentAttendance.getXName());
输出:"null"
但这段代码工作正常:
xValues[index] = currentAttendance.getxValues();
输出:7
任何帮助谢谢你们,,,,谢谢,我爱你
这是我的代码段:
ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
int count = (int) dataSnapshot.getChildrenCount();
int[] xValues = new int[count];
int[] yValues = new int[count];
String[] xNames = new String[count];
int index = 0;
for (DataSnapshot myDatabases : dataSnapshot.getChildren()) {
CurrentAttendance cA = myDatabases.getValue(CurrentAttendance.class);
if (cA != null) {
xNames[index] = String.valueOf(cA.getXName());
xValues[index] = cA.getUserCount();
}
if (cA != null) {
yValues[index] = cA.getCurrentAttendance();
}
index++
}
}
}
哔哔one
人到中年有点甜
随时随地看视频慕课网APP
相关分类