Android imitation wechat contact list letter sideslip control

Imitating wechat contact list letter sideslip control, the sideslip control refers to the following Blogs:

Android implements A-Z alphabetic sorting and filtering search functions of listview

First, analyze how the letter sideslip control should be implemented, and calculate the average height of each letter according to the height of the sideslip control and the number of letters.

Draw each letter under the OnDraw () method of view

Then take a look at the interception of touch events

After the sideslip control is completed, analyze how the grouping interface is implemented. Different groups have different letters as titles, which can be implemented with listview. In the adapter used in listview, there is a method getitemviewtype() method to distinguish and return multiple types of views. Here we have two kinds, one is the title and the other is the contact information; Those new friends and group chat at the top can be implemented with addheaderview () of listview. However, it is not convenient to implement grouping with the baseadapter provided with the SDK. In fact, we can further package it;

First, let's take a look at the most basic adapter encapsulation:

This simpleadapter implements the most basic method of data based on list, so that each time you inherit baseadapter, you don't need to implement some basic methods. Next, let's take a look at the further encapsulation of the adapter for better grouping:

GitHub address of the project (built based on Android studio): https://github.com/yuhengye/LetterSort

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>