This menu view
is made to recreate the demo more easely.
<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>
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"
... />
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);
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;
}
});
Using the DuoOptionView
to fill the DuoMenuView
. You can see how it's used here.