我正在尝试从Firebase检索一些数据, 并且我只想在“组织”等于组织中当前登录名的情况下检索服务“ NOT Services”,但是当我尝试运行此代码时,它不会检索任何东西
这是我的代码:
reservation=new Reservation();
ListView = (android.widget.ListView) findViewById(R.id.ListView);
database = FirebaseDatabase.getInstance();
mAuth = FirebaseAuth.getInstance();
user = mAuth.getCurrentUser();
userId = user.getUid();
name=database.getReference().child("client").child(userId).child("name").toString();
//ref = database.getReference().child("reservaiton");
DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference itemsRef = rootRef.child("reservaiton");
Query query=itemsRef.orderByChild("org").equalTo(name);
list = new ArrayList<>();
list1 = new ArrayList<>();
adapter = new ArrayAdapter<String>(this, R.layout.requesttext,R.id.requestInfo,list);
query.addValueEventListener(new ValueEventListener() {
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot ds : dataSnapshot.getChildren()) {
String str;
reservation = ds.getValue(Reservation.class);
str = reservation.getService().toString() + " \n\n ";
list.add(str);
list1.add(reservation);
}
ListView.setAdapter(adapter);
ListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(ApproveResrvation.this, orginforequest.class);
intent.putExtra("reservation", (Serializable) list1.get(position));
startActivity(intent);
}
});
}
@Override
public void onCancelled(DatabaseError databaseError){
}
});
这是我的预订课程:
package com.example.atheer.booklyv1;
public class Reservation {
private String approved;
private String date;
private String service;
private String org, orgID, resNum;
private String time,Uid;
private int num;
public String getUid() {
return Uid;
}
public void setUid(String uid) {
Uid = uid;
}
public String getOrgID() {
return orgID;
}
public void setOrgID(String orgID) {
this.orgID = orgID;
}
public String getResNum() {
return resNum;
}
public void setResNum(String resNum) {
this.resNum = resNum;
}
public Reservation(String approved, String date, String service, String org, String orgID, String resNum, String time, String uid, int num) {
this.approved = approved;
this.date = date;
this.service = service;
this.org = org;
this.orgID = orgID;
this.resNum = resNum;
this.time = time;
Uid = uid;
this.num = num;
}
public Reservation(){
}
public Reservation(String approved, String date, String service, String org, String time, int num) {
this.approved = approved;
this.date = date;
this.service = service;
this.org = org;
this.time = time;
this.num = num;
}
public String getApproved() {
return approved;
}
public void setApproved(String approved) {
this.approved = approved;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getService() {
return service;
}
public void setService(String service) {
this.service = service;
}
public String getOrg() {
return org;
}
public void setOrg(String org) {
this.org = org;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
}