更新时间:2023-11-09 20:27:58
You'll need to override FirebaseListAdapter.parseDataSnapshot()
to extract the right value from the DataSnapshot
:
FirebaseListAdapter<String> listAdapter = new FirebaseListAdapter<String>
(this, String.class, R.layout.menu_list_item, restaurantMenuRef ) {
@Override
protected String parseSnapshot(DataSnapshot snapshot) {
return snapshot.child("category").getValue(String.class);
}
@Override
protected void populateView(View v, String s, int position) {
TextView menuName = (TextView)v.findViewById(R.id.menuName);
menuName.setText(s);
}
};