且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用firebase android在多个节点中查询特定的子值

更新时间: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);
    }
};

相关阅读

推荐文章