Android MaterialDrawer:选择突出显示&;在项目上,单击帐户标题的侦听器
这个问题非常特定于定制 我需要自定义我的帐户标题,如下所示:Android MaterialDrawer:选择突出显示&;在项目上,单击帐户标题的侦听器,android,materialdrawer,Android,Materialdrawer,这个问题非常特定于定制 我需要自定义我的帐户标题,如下所示: 任何时候都只有一个账户 点击标题(整个区域)应该会给我一个DroperClickListener#onItemClick回调 通过重定向配置文件列表侦听器,我成功地获得了DrawerClickListener#onItemClick回调。但标题选择在方向更改时丢失。 [我已使用保存的实例状态设置]。此外,onItemClick提供空IDraWrite,因为它不是适配器的一部分 我是不是把它弄得太复杂了,或者PrimaryDrawerI
您的问题分为多个问题。让我从第一个问题开始
build
您的AccountHeader
可以只提供一个概要文件。构建标头后,您可以随时更新和修改此单一配置文件,只需调用:
//create the profile
final IProfile profile = new ProfileDrawerItem().withName("Mike Penz").withEmail("mikepenz@gmail.com").withIcon("https://avatars3.githubusercontent.com/u/1476232?v=3&s=460").withIdentifier(100);
//build your drawer or do your logic
...
//modify the profile
profile.withName("new name");
//notify the header about the changed profile
headerResult.updateProfile(profile);
帐户标题中的某个位置
,将触发帐户标题选择视图ClickListener的
.withOnAccountHeaderSelectionViewClickListener(new AccountHeader.OnAccountHeaderSelectionViewClickListener() {
@Override
public boolean onClick(View view, IProfile profile) {
return false;
}
})
布局应呈现为具有额外字段的配置文件
由于问题似乎不清楚,请补充更多细节
加载要更改为加载基于url的图像的ImageHolder
示例应用程序包含一个CustomDrawerItem
,它通过url加载图标:抽屉项单击侦听器
您必须在setupNavigation中声明该方法。在导航页脚项目中,声明
List<IDrawerItem> stockyItems = new ArrayList<>();
最后你必须通过这个物体
stockyItems.add(primaryDrawerItem);
完成
stockyItems.add(primaryDrawerItem);