这是我的代码:
mFirebaseDatabae = FirebaseDatabase.getInstance();
mMessageReference = FirebaseDatabase.getInstance().getReference().child("memos");
serchButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mMessageReference.orderByChild("title").equalTo("z").addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Toast.makeText(SerchActivity.this, "print", Toast.LENGTH_LONG).show();
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
});
这是我的Firebase树:
只有当标题是z?
时,才能打印标题答案 0 :(得分:2)
像这样的方式......
for (DataSnapshot messageSnapshot : dataSnapshot.getChildren()) {
String title= (String) messageSnapshot.child("title").getValue();
}