我在其中使用MaterialDrawer Library,将抽屉折叠成Firebase数据库的名称及其子项的名称

但是,当我添加一个子项目时,直到我折叠并再次展开该折叠项目后,它才会出现

RootRef.addChildEventListener(new ChildEventListener() {
        @Override
        public void onChildAdded(DataSnapshot dataSnapshot, String s) {
            final int[] t = {0};
            Log.i("s =", String.valueOf(dataSnapshot.getKey()));
            final ExpandableDrawerItem IntentItemDrawer;

            result.addItem(IntentItemDrawer = new ExpandableDrawerItem()
                    .withName(String.valueOf(dataSnapshot.getKey()))
                    .withIcon(GoogleMaterial.Icon.gmd_collection_case_play)
                    .withIdentifier(t[0]++).withSelectable(false)
                    .withSubItems());

            RootRef.child(String.valueOf(dataSnapshot.getKey()))
                    .addChildEventListener(new ChildEventListener() {
                @Override
                public void onChildAdded(DataSnapshot dataSnapshot, String s) {
                    IntentItemDrawer.withSubItems(new SecondaryDrawerItem()
                            .withName(String.valueOf(dataSnapshot.getKey()))
                            .withLevel(2)
                            .withIcon(GoogleMaterial.Icon.gmd_8tracks)
                            .withIdentifier(t[

最佳答案

来自github的示例:



//modify an item of the drawer
item1.withName("A new name for this drawerItem").withBadge("19").withBadgeStyle(new BadgeStyle().withTextColor(Color.WHITE).withColorRes(R.color.md_red_700));
//notify the drawer about the updated element. it will take care about everything else
result.updateItem(item1);





result.updateItem(/您的项目/);

要扩展视图,请尝试以下行:


  result.getAdapter()。toggleExpandable(position);

10-07 19:41
查看更多