Headings under Navigation Drawer

251 Views Asked by At

How to add Headings in drawer layout. For example in YouTube application it has Headings in it's drawer like Subscription and from YouTube... So How we can add such Headings in Drawer Layout?

Check below image I want to add heading like "Subscription" used in this image.

enter image description here

1

There are 1 best solutions below

0
On

The magic is happening in the Adapter that is feeding views to the ListView.

When a ListView is scrolled, it has to display whatever row is next in the data set. Instead of having to do this on their own, ListViews are backed by an Adapter. The ListView essentially asks the adapter for the next view (naming an index value) every time it needs to scroll up or down.

The Adapter can pass the ListView whatever it wants. When the ListView asks for row x (an index value), the Adapter can look at the data set and see that row x should be a special header. The adapter builds or recycles a special header view and passes it to the list view.

See the List View Guide for example code.