javaandroidmaterialdrawer

MaterialDrawer add profile option


I'm using the MaterialDrawer library by Mike Penz.

I made an AccountHeader and now wondered how to add such an "add Account" button (see the picture). Is there allready a provided method how to do this? Like by pressing this button sth appears to let you insert information of a new account?

enter image description here


Solution

  • The AccountHeaderBuilder.build() function returns a AccountHeader object. You should keep the reference to this one, as it will allow you to update contents of the AccountHeader at a later time.

    So you'll create your AccountHeader like this

    AccountHeader headerResult = new AccountHeaderBuilder()
        .withActivity(this)
        .addProfiles(...)
        .build();
    

    After that you have the headerResult if you take a look in the javadoc you will see that there are 2 methods which will be useful for you.

    There is addProfiles and addProfile which allows you to add a new profile to the drawer. Equally there is removeProfile, and updateProfile (which you will use when one profile was modified)