Adarsh Raj
Adarsh Raj

Reputation: 193

Adding a layout in between a listview

I want to add some headers in between list items in a listview. For eg:

My list is :

In my Listview, i want it to be like this:

Please help me on how can i add/inflate views in between Its a custom listview, I have a custom adapter which inflates the listview. The days(Monday, tuesday) card has other elements like ImageView, button, textView etc.

Upvotes: 2

Views: 75

Answers (1)

Dima
Dima

Reputation: 443

You are looking for headers and I really encourage you to use a RecyclerView instead of a ListView.

But, creating adapters manually usually takes a lot of boilerplate, so we can use this library to speed up development: https://github.com/mikepenz/FastAdapter

Check those files to see how headers are implemented there:

  • app/src/main/java/com/mikepenz/fastadapter/app/adapters/StickyHeaderAdapter.java
  • app/src/main/java/com/mikepenz/fastadapter/app/StickyHeaderSampleActivity.java

Upvotes: 1

Related Questions