Reputation: 51
I'm trying to get the ID of my fields. But when I click on the elements of my listview, it shows me identifiers that does not exist in the database and changes to each click.
Display:
How can I get the id of the address selected in the listview?
Upvotes: 2
Views: 125
Reputation: 57
So, where is Geneva put what you want.
Inside onClick PositiveButton:
db.collection("Adresse").whereEqualTo("Adresse", "Geneva").addSnapshotListener(new EventListener<QuerySnapshot>() {
@Override
public void onEvent(@Nullable QuerySnapshot queryDocumentSnapshots, @Nullable FirebaseFirestoreException e) {
if (e != null) {
Log.w(TAG, "listen:error", e);
return;
}
for (DocumentChange dc : queryDocumentSnapshots.getDocumentChanges()) {
String docid = dc.getDocument().getId();
Toast.makeText(getApplicationContext(), docid, Toast.LENGTH_SHORT).show();
}
}
});
Upvotes: 1