Skip to content
This repository has been archived by the owner on Apr 30, 2020. It is now read-only.
Fabio Biola edited this page Feb 23, 2015 · 4 revisions

How can I get my action bar / toolbar?

From your Activity:

// get toolbar
this.getToolbar();
// get Action Bar
this.getSupportActionBar();

From your Fragment:

// get toolbar
((MaterialNavigationDrawer)this.getActivity()).getToolbar();
// get action bar
this.getActivity().getSupportActionBar();

How can I get the current Section?

From your Activity:

this.getCurrentSection();

From your Fragment:

((MaterialNavigationDrawer)this.getActivity()).getCurrentSection();

How can I add/remove/change account asynchronously?

First you should add/change your account:

account = new MaterialAccount( ... );
addAccount(account); // add a new account 
account.setBackground( ... ); // change account informations

And then call the notifyAccountDataChanged method on ui thread:
(if you want to remove the account you should move the call into the main thread)

runOnUiThread(new Runnable() {
        @Override
        public void run() {
            // removeAccount(account);
            notifyAccountDataChanged();
        }
    });

How can I get the current Account?

From your Activity:

this.getCurrentAccount();

From your Fragment:

((MaterialNavigationDrawer)this.getActivity()).getCurrentAccount();

How can I get an account knowing his current position?

From your Activity:

int position;
this.getAccountAtCurrentPosition(position);

From your Fragment:

((MaterialNavigationDrawer)this.getActivity()).getAccountAtCurrentPosition(position);

How enable the toolbar arrow effect?

for default, it is disabled. If you want to re-enable it add this to your init() method:

allowArrowAnimation();

How can I takes the toolbar color when a section with color is clicked?

Well, if you want to follow exactly the material design guidelines you have not to do it. If you want to mock this functionality, on your extended Fragment class insert this code:

@Override
    public void onResume() {
        super.onResume();
        ((MaterialNavigationDrawer)this.getActivity()).changeToolbarColor(primaryColor,primaryColorDark);
    }

How enable the ripple support on lower devices?

Ripple support activate the ripple when a section is clicked/tapped. As default is enabled on Lollipop devices and on Kitkat devices if Theme use a TranslucentKitKatStatusBar Theme To enable it on all 14+ devices, add this line to your custom theme:

<item name="rippleBackport">true</item>

I want to set other value than numbers as notification

You could set a Text as your notification using:

section.setNotificationsText("MyValue");

How I can change the section from another section?

If your fragment is a section target, you can get the MaterialNavigationDrawer parsing it from the fragment.
example:

 ((MaterialNavigationDrawer)this.getActivity()).setFragment( ... )
 ((MaterialNavigationDrawer)this.getActivity()).setSection( ... )
 ((MaterialNavigationDrawer)this.getActivity()).setSectionChild( ... )