私のデータベースには、以下の通りである:子のリストを取得します
List_of_users>
sunil dhakal>
departmnet:"Computer Science",
level:"Level 3 Undergraduate",
name:"sunil dhakal",
student_id:"1412361",
username:"[email protected]",
root.child("List_of_user").addValueEventListener(new ValueEventListener() {
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot data :dataSnapshot.getChildren()){
if (data.child(department).exists()&& data.child(level).exists()){
Set<String> set = new HashSet<String>();
Iterator i = dataSnapshot.child("List_of_users").getChildren().iterator();
while (i.hasNext()) {
set.add(((DataSnapshot) i.next()).getKey());
}
list_of_rooms.clear();
list_of_rooms.addAll(set);
arrayAdapter.notifyDataSetChanged();
}
else{
Toast.makeText(searchuser.this,"There is not user with the department and level that was selected",Toast.LENGTH_SHORT).show();
return;
}
}
}
public void onCancelled(DatabaseError databaseError) {}
});
私は、ユーザーが選択することができるスピナーを持っていますその部門とレベルのデータベース内のすべてのユーザーをリストするボタンをクリックします。
この形式ですそれを働かせようとする –