奇怪的问题:
此代码:
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++
}
}
}
数据库结构:
答案 0 :(得分:0)
要解决此问题,请使用以下代码行:
search
您的logcat中的输出将是:
pattern = re.compile('series-[abcd]', re.IGNORECASE)
def interesting(word):
return bool(pattern.search(word))
要获取所有用户名,请使用以下代码行:
String uid = FirebaseAuth.getInstance().getCurrentUser().getUid();
DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference uidRef = rootRef.child("Attendance").child(uid);
ValueEventListener valueEventListener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String xname = dataSnapshot.child("xname").getValue(String.class);
Log.d(TAG, xname);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
Log.d(TAG, databaseError.getMessage()); //Don't ignore errors!
}
};
uidRef.addListenerForSingleValueEvent(valueEventListener);
输出将是:
Vaianaa