3

我在 mikepenz 材料抽屉中使用自定义标题。我怎样才能得到标题的onClick。我可以使用 onDrawerItemClickListener 来获取自定义标题的点击事件吗?

result = new DrawerBuilder()
                .withActivity(this)
                .withSelectedItem(-1)
                .withSliderBackgroundColorRes(R.color.white)
                .withToolbar(toolbar)
                .withStickyHeader(R.layout.nav_header)
                .withTranslucentStatusBar(true)
                .withDisplayBelowStatusBar(true)
                .addDrawerItems(
                       //Drawer Items
                ).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                    @Override
                    public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {


                })
                .build();
4

2 回答 2

2

如果您已经定义了一个标题(所以不是AccountHeader),您可以通过在构建后调用以下命令来获取对该视图的引用Drawer

Drawer.getHeader()

粘性标题非常相似:

Drawer.getStickyHeader()

这将为您返回标题的视图,并允许您设置所需的任何侦听器。

于 2017-05-27T03:09:24.970 回答
0

你可以在这里查看。文档中提到了如何处理标题部分及其事件。

于 2017-05-16T10:12:36.223 回答