I used the material drawer library to build the drawer. Instead of displaying a list of users(num 4 and 5), I want to display a list of objects that belong to user ( for example :CARS)in the header drawer. In fact, only one user logs into the application (num 1) and the selected object that belong to him(like : one of his cars) is showing in num #2 and 3...
by click on each object ,the profile pic(num 1) will not change or replace by choosed object picture.
here is image of what i want.
in this URL @mikepenz explain about it but i didnt get it at all.
here is my class :
public class MikePenz {
private static Drawer drawer;
private static AccountHeader accountHeader;
AccountHeader.OnAccountHeaderSelectionViewClickListener mOnAccountHeaderSelectionViewClickListener;
View mAccountSwitcherArrow;
Activity activity;
public static void mikepenz(final Activity activity, Toolbar toolbar) {
//after oncreate and before items start
AccountHeader headerResult = new AccountHeaderBuilder()
.withActivity(activity)
.withHeaderBackground(R.mipmap.car)
.addProfiles(
new ProfileDrawerItem().withName("pejman ghorbany").withEmail("pejman.gh66@gmail.com").withIcon(R.drawable.ic_build_black_24dp),
new ProfileDrawerItem().withName("sepahdar ghorbani").withEmail("sepahdar.gh41@gmail.com").withIcon(R.drawable.ic_check_box_black_24dp)
)
.withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {
@Override
public boolean onProfileChanged(View view, IProfile profile, boolean current) {
return false;
}
})
.build();
//after on create and before items end
//if you want to update the items in a later time it recommanded to keep it in a variable;
PrimaryDrawerItem drawerItem1 = new PrimaryDrawerItem().withIdentifier(10).withName("home");
PrimaryDrawerItem drawerItem2 = new PrimaryDrawerItem().withIdentifier(2).withName("settin2");
PrimaryDrawerItem drawerItem3 = new PrimaryDrawerItem().withIdentifier(3).withName("settin3");
SecondaryDrawerItem drawerItems1 = (SecondaryDrawerItem) new SecondaryDrawerItem().withIdentifier(6).withName("s6");
//Create the drawer and remember the 'drawer' result object
drawer = new DrawerBuilder()
.withActivity(activity)
.withAccountHeader(headerResult)
.withToolbar(toolbar)
//create the account header
.addDrawerItems(
new SecondaryDrawerItem().withName("setting").withIcon(R.drawable.ic_build_black_24dp),
drawerItem1,
new SecondaryDrawerItem().withName("build").withSubItems(drawerItem2, drawerItems1).withIcon(R.drawable.ic_build_black_24dp),
drawerItem3
)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
switch (position) {
case 1:
break;
case 2:
Toast.makeText(activity, "clicked 2 ", Toast.LENGTH_SHORT).show();
break;
case 3:
Toast.makeText(activity, "clicked 3 ", Toast.LENGTH_SHORT).show();
break;
case 4:
Toast.makeText(activity, "clicked 4 ", Toast.LENGTH_SHORT).show();
break;
case 5:
Toast.makeText(activity, "clicked 5 ", Toast.LENGTH_SHORT).show();
break;
}
return true;
}
})
.build();
}
}