1

我正在使用MaterialDrawer 库,在其中我将抽屉设置为折叠项目获取 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[
4

1 回答 1

3

来自 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);

于 2017-01-01T08:24:56.887 回答