I'm getting contacts from an app with a cursor interface and I have to give alphabetical headers to sort them in recyclerview, But I can't use itemdecorator or any external libraries. Suggestions?
Asked
Active
Viewed 350 times
0
-
`RecyclerView` itself comes from an external library. So, it would appear that you can use external libraries. – CommonsWare Feb 01 '21 at 13:15
-
Let's say it kind of rule to not use other libraries. – Otaku San Feb 01 '21 at 13:26
-
OK. But you can certainly *look* at the source code to those libraries and see how they approached the problem. Also, there has been a lot written about this already: https://duckduckgo.com/?q=recyclerview+section+headers, such as https://stackoverflow.com/a/44640397/115145. – CommonsWare Feb 01 '21 at 13:30
-
You can use different types of RecyclerView.ViewHolder with different layouts. First will be your alphabetical header, second - contact. You need to make 2 different recycler item types, sort and group items, pass to RecylerView and return different RecyclerView.ViewHolder depending on item type in onCreateViewHolder. – Artem Chernousov Feb 01 '21 at 13:31