我正在使用 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(/你的项目/);
要扩展 View ,请尝试以下行:
result.getAdapter().toggleExpandable(position);
关于android - 刷新折叠的 itemDrawer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41414211/