我的数据库就是这个 - >
{
"140107": {
"Guest First Name": "As",
"Guest Last Name": "Rodrigues",
"Email": "aaa@yahoo.com.br",
"Country": "Brazil",
"Check-In date": "11-Jun-2016",
"Check-Out date": "12-Jun-2016",
"Room": "Cama Casal com suite",
"Unit No": 1,
"Subtotal": 90,
"Revenue": 90,
"Currency": "BRL",
"Create Date": "19-May-2016"
}
}
我的代码就是这个
public void ProcuraReservaporemail(){
String email = FirebaseAuth.getInstance().getCurrentUser().getEmail();
myRef = database.getReference("reserva/");
myRef.orderByChild("Email").equalTo(email).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
// Reserva reserva1;
for(DataSnapshot childSnapshot: dataSnapshot.getChildren()) {
// reserva1 = new Reserva(childSnapshot);
String Unit = (String) childSnapshot.child("Unit No").getValue();
textview2.setText(Unit);
textview2.setText( childSnapshot.child("Unit No").getValue(String.class));
}
}
指令childSnapshot.child("Unit No").getValue(String.class)
生成错误,因为我的银行有这个空格。我必须改变它,以便不再发生这个错误吗?我想改变我的银行越来越多的工作。没有特定的错误,活动停止工作。
答案 0 :(得分:0)
尝试使用:
(String) childSnapshot.child("Unit No").getValue()
或
String.valueOf(childSnapshot.child("Unit No").getValue())