So I have followed your tutorial and I came up with this code:
//initialize and create the image loader logic
DrawerImageLoader.init(new AbstractDrawerImageLoader() {
@Override
public void set(ImageView imageView, Uri uri, Drawable placeholder) {
Picasso.with(imageView.getContext()).load(uri).placeholder(placeholder).into(imageView);
}
@Override
public void cancel(ImageView imageView) {
Picasso.with(imageView.getContext()).cancelRequest(imageView);
}
});
// Create the AccountHeader
AccountHeader headerResult = new AccountHeaderBuilder()
.withActivity(this)
.withSelectionListEnabledForSingleProfile(false)
.withHeaderBackground(R.drawable.side_nav_bar)
.addProfiles(
new ProfileDrawerItem().withName(u.getUsername()).withEmail(u.getEmail()).withIcon(Uri.parse(BuildConfig.BASE_API_URL + profilePictureUrl))
)
.withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {
@Override
public boolean onProfileChanged(View view, IProfile profile, boolean currentProfile) {
return false;
}
})
.build();
Drawer result = new DrawerBuilder()
.withActivity(this)
.withAccountHeader(headerResult)
.withToolbar(toolbar)
.addDrawerItems(
new PrimaryDrawerItem().withIdentifier(0).withName(R.string.dashboard).withIcon(FontAwesome.Icon.faw_tachometer)
)
.addStickyDrawerItems(new PrimaryDrawerItem().withIdentifier(11).withName(R.string.sign_out).withIcon(FontAwesome.Icon.faw_lock))
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
// do something with the clicked item :D
if (drawerItem != null) {
Intent intent = null;
if (drawerItem.getIdentifier() == 0){
intent = new Intent(getApplicationContext(), DashboardActivity.class);
}
else if(drawerItem.getIdentifier() == 1){
}
else if(drawerItem.getIdentifier() == 11){
Intent i = new Intent(getApplicationContext(), SplashScreenActivity.class);
MainProvider.sharedInstance().logOut(SidebarMenu.this);
Toast.makeText(SidebarMenu.this, "Logged Out", Toast.LENGTH_SHORT).show();
startActivity(i);
}
if(drawerItem.getIdentifier() != 11){
startActivity(intent);
}
}
return false;
}
})
.withSavedInstance(savedInstanceState)
.build();
Now what I fail to do is add above the profile picture a header with the app's logo found in R.drawable.logo . I mention that I trying to do that without a custom header from ground zero...I really like the one generated by the library. Is there an option for adding a logo?
where and how do you want to add a logo? do you have a design how it should be like?
Yes I would like to add the logo above the user's profile picture. (I mention that I have disabled the option to have multiple accounts .... the sidebar is static from this point of view, having only one user at all times...so above its profile picture I want to display the apps logo...I thought I could find an option for that, like that withStickyFooter or something)
@dev2961io well there is the StickyHeader but as you disabled profiles anyways. Why don't you just provide a custom header? There is no need to use the AccountHeader for this then
Thank you for your suggestion @mikepenz. I have created a custom header and everything is fine now. But I have one more question: Can I use the fontawesome icons somewhere else in my app. For example I want to display the same icons I am using for the drawerItems in the activity toolbar. For example:
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setIcon(FontAwesome.Icon.faw_tachometer);
But the setIcon does not recognize it as an icon. Any idea?
The font awesome icons are provided via: https://github.com/mikepenz/Android-Iconics
Thank you very much!