i want to retrieve the keys into FirebaseListAdapter not the values like this example:
so i want to show "Cat" and "Dog" in the listview but i don't know how to do this cuz i searched a lot but found nothing.
The default implementation of FirebaseListAdapter
calls getValue()
with the class you specified when constructing the adapter. By overriding parseSnapshot
you can determine what part of each DataSnapshot
is handed to populateView()
. To get the key:
FirebaseListAdapter<String> firebaseListAdapter = new FirebaseListAdapter<String>(
this,
String.class,
android.R.layout.simple_list_item_1,
databaseReference
) {
@Override
protected String parseSnapshot(DataSnapshot snapshot) {
return snapshot.getKey();
}
@Override
protected void populateView(View v, String model, int position) {
TextView textView = (TextView) v.findViewById(android.R.id.text1);
textView.setText(model);
}
};