【发布时间】:2020-10-31 21:54:13
【问题描述】:
如您所见,有一些示例配置文件项目绑定到抽屉进行测试(它由 IProfile 制成),但我想从 arraylist<user> 获取它们
这是示例代码:
final IProfile profile = new ProfileDrawerItem().withName(LoginActivity.loggedInUser.get(0).getMobile()+"").withEmail(LoginActivity.loggedInUser.get(0).getResponse()).withIdentifier(100);
final IProfile profile2 = new ProfileDrawerItem().withName("Bernat Borras").withEmail("alorma@github.com").withIdentifier(101);
final IProfile profile3 = new ProfileDrawerItem().withName("Max Muster").withEmail("max.mustermann@gmail.com").withIdentifier(102);
final IProfile profile4 = new ProfileDrawerItem().withName("Felix House").withEmail("felix.house@gmail.com").withIdentifier(103);
final IProfile profile5 = new ProfileDrawerItem().withName("Mr. X").withEmail("mister.x.super@gmail.com").withIdentifier(104);
final IProfile profile6 = new ProfileDrawerItem().withName("Batman").withEmail("batman@gmail.com").withIdentifier(105);
此配置文件将添加到 accountHeader 和 addProfiles(profile,profile1,...); 方法中。
但我想从数组中设置配置文件项...
我正在尝试从我的用户那里创建一个 IProfile 数组:
喜欢以这种方式获取个人资料:
if(!Arrays.userCars.isEmpty()) {
for (int i = 0; i <= Arrays.userCars.size(); i++) {
Arrays.profiles.add(new ProfileDrawerItem()
.withName(Arrays.userCars.get(i).getName())
.withEmail(Arrays.userCars.get(i).getCarCompany().toString())
.withIdentifier(103 + i));
}
}
但是如何从profiles 数组中获取这些项目并在addProfiles() 方法中使用?
请记住,这个方法来自图书馆,我不能改变它。
【问题讨论】:
标签: android arrays navigation-drawer profile materialdrawer