Skip to content

Latest commit

 

History

History
85 lines (65 loc) · 2.76 KB

MENU_VIEW.md

File metadata and controls

85 lines (65 loc) · 2.76 KB

Duo Menu View

This menu view is made to recreate the demo more easely.

1. Add the DuoMenuView to your drawer.

<nl.psdcompany.duonavigationdrawer.views.DuoDrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    ... >

    <nl.psdcompany.duonavigationdrawer.views.DuoMenuView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/menu"
        android:tag="menu"
        ... />
        
</nl.psdcompany.duonavigationdrawer.views.DuoDrawerLayout>

2. Add the your own header and footer

Add your own header and footer view to the DuoMenuView using the attributes app:footer and app:header.

<nl.psdcompany.duonavigationdrawer.views.DuoMenuView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:tag="@string/tag_menu"
    app:footer="@layout/view_footer"
    app:header="@layout/view_header"
    ... />

3. Initialize the menu view.

Create your own menu adapter and initialize the menu view.

DuoMenuView duoMenuView = (DuoMenuView) findViewById(R.id.menu);
MenuAdapter menuAdapter = new MenuAdapter(mMenuOptions);
duoMenuView.setAdapter(menuAdapter);

4. Start listening to events.

duoMenuView.setOnMenuClickListener(new DuoMenuView.OnMenuClickListener() {
    @Override
    public void onFooterClicked() {
        // If the footer view contains a button
        // it will launch this method on the button click. 
        // If the view does not contain a button it will listen
        // to the root view click.
    }

    @Override
    public void onHeaderClicked() {

    }

    @Override
    public void onOptionClicked(int position, Object objectClicked) {
            // Set the toolbar title
        setTitle(mTitles.get(position));

        // Set the right options selected
        mMenuAdapter.setViewSelected(position, true);

        // Navigate to the right fragment
        switch (position) {
            default:
                goToFragment(new MainFragment(), false);
                break;
    }
});

5. Using the DuoOptionView (Optional)

Using the DuoOptionView to fill the DuoMenuView. You can see how it's used here.