gpt4 book ai didi

android - MaterialDrawer:选择突出显示和在项目上单击帐户标题的监听器

转载 作者:行者123 更新时间:2023-11-30 01:37:52 26 4
gpt4 key购买 nike

这个问题非常具体 https://github.com/mikepenz/MaterialDrawer定制。

我需要按如下方式自定义我的帐户标题:

  1. 任何时候都只有一个帐户
  2. 点击标题(整个区域)应该给我 DrawerClickListener#onItemClick 回调

我通过重定向配置文件列表监听器设法获得 DrawerClickListener#onItemClick 回调。但是标题选择在方向改变时丢失了。[我已经设置了保存的实例状态]。此外,onItemClick 提供 null IDrawerItem,因为它不是 Adapter 的一部分。

我是不是让它太复杂了,或者 PrimaryDrawerItem 本身可以扩展为看起来像配置文件项?

  1. 布局应该像带有额外字段的配置文件一样呈现
  2. 加载 ImageHolder 以更改为加载基于 url 的图像

最佳答案

您的问题分为多个问题。那么让我从第一个问题开始。

  1. There going to be only one account at any time

如果您构建您的AccountHeader,您可以只提供一个配置文件。构建 header 后,您可以随时更新和修改此单个配置文件,只需调用:

//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);
  1. Clicking on header (whole area) should give me DrawerClickListener#onItemClick callback

如果您单击 AccountHeader 中的某处,这将触发 OnAccountHeaderSelectionViewClickListener

.withOnAccountHeaderSelectionViewClickListener(new AccountHeader.OnAccountHeaderSelectionViewClickListener() {
@Override
public boolean onClick(View view, IProfile profile) {
return false;
}
})
  1. Layout should be rendered like profile with extra fields

请添加更多细节,因为问题似乎不清楚。

  1. Loading ImageHolder to be changed to load url based images

示例应用程序包含一个 CustomDrawerItem,它通过 url 加载图标:CustomUrlPrimaryDrawerItem

关于android - MaterialDrawer:选择突出显示和在项目上单击帐户标题的监听器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34892517/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com