How to realize Recycleview suspension sticky head plus right alphabet navigation by Android
This article mainly introduces Android how to achieve Recycleview suspension sticky head plus right letter navigation, the article is very detailed, has a certain reference value, interested friends must read it!
The idea of realization is:
The linkage on the right can be achieved using the scrollToPositionWithOffset method of adapter in recycyeview. On the left is recycleview. The city data returned by the backend is of this type:
The copy code is as follows:
{"returnCode": 1, "returnMsg": "Operation succeeded", "data": [{"startWord": "A", "trainCityList": [{"cityId": 531, "cityName": "Ang Xi", "code": null}, {"cityId": 2137
I did a layer of encapsulation.
1. Create an entity class to encapsulate the subscript and city name:
Public class ContactModel {private String index; private String name; public ContactModel (String name) {this.index = NewFirstLetterUtil.getFirstLetter (name); this.name = name;} public String getIndex () {return index;} public String getName () {return name;}}
two。 Encapsulate the data returned by the server:
List contacts = new ArrayList (); for (int item0)