I am updating the Navigation Drawer in my app. I want to add section dividers as the Gmail App has. How do I add them? Just add them as views, which is a simple approach. Bu
I used headerview and footerview to add the image on top and divider at the bottom. The divider is a View.
drawer_list_footer_divider.xml
drawer_list_footer_view.xml
and in my code:
private void setUpHeaderAndFooter() {
LayoutInflater inflater = getLayoutInflater();
View header = (View) inflater.inflate(R.layout.drawer_list_header_view,
mDrawerList, false);
mDrawerList.addHeaderView(header, null, false);
View footer_divider = (View) inflater.inflate(
R.layout.drawer_list_footer_divider, null, false);
mDrawerList.addFooterView(footer_divider, null, false);
// This view is Settings view
View footer = (View) inflater.inflate(R.layout.drawer_list_footer_view,
mDrawerList, false);
footer.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mDrawerLayout.isDrawerOpen(Gravity.LEFT)) {
mDrawerLayout.closeDrawer(Gravity.LEFT);
}
if (android.os.Build.VERSION.SDK_INT < 11) {
startActivity(new Intent(MainActivity.this,
Settings1Activity.class)
.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT));
} else {
startActivity(new Intent(MainActivity.this,
Settings2Activity.class)
.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT));
}
}
});
mDrawerList.addFooterView(footer, null, true);
}