Skip to content
This repository has been archived by the owner on Apr 30, 2020. It is now read-only.

Accounts

Fabio Biola edited this page Feb 23, 2015 · 2 revisions

A collection of user data.
This library not implements an Android Account, it allows only to set user data in your navigation drawer.

Creating and add an Account in init method

NOTE: if you want to add an account asynchronously, please see the FAQ related

MaterialAccount account = new MaterialAccount(this.getResources(),"Name and Surname","subtitle or email",R.drawable.photo, R.drawable.background);
this.addAccount(account);

You can add how many account you want, but It is suggested to have at least one account setted into the init() method when the drawer is created.
For other constructor, check the list below:

public MaterialAccount(Resources resources,String title, String subTitle, int photo,Bitmap background)

public MaterialAccount(Resources resources,String title, String subTitle, int photo,int background)

public MaterialAccount(Resources resources,String title, String subTitle, Bitmap photo, int background)

public MaterialAccount(Resources resources,String title, String subTitle, Bitmap photo, Bitmap background)

Update the account information asynchronously

Change your account information, then call this MaterialNavigationDrawer activity method:

notifyAccountDataChanged();

N.B. If you are in another thread, make sure to call this method from the main thread calling runOnUiThread()

Account Listener

If you want to know when the user switch his account with another, or when user clicks on his current account, you should implement an MaterialAccountListener for reaching these events.

You can attach this listener in your init method with the following code:

this.setAccountListener(this); // or new MaterialAccountListener() {}