Android imitation phone address book address selection function
I think it's a good address selection design, and I found that it is also used in some apps. Or the renderings first
Idea:
1. The effect is modeled on the similar address book style realized by the online God; 2. A-Z on the right is a custom bar, which sets the click to listen event and the dialog box pops up. 3. The key is the adapter, which determines the display and hiding of letters. 4. Tool classes such as Chinese character to Pinyin and sorting by initial letter are used. 5.3 the jump of activities is realized by callback, and each activity implements callback, In this way, you can jump directly from the district activity to the home page. 6. The data is implemented by calling my local interface. If you don't have data, I can find a way to provide you with the provincial and urban data interface for testing. Loading data is implemented using the volley framework
A structure of code
1. Some codes of custom bar on the right
First override the OnDraw method
Override the dispatchtouchevent method
Outward development interface
2. The key code of adapter, taking the adapter of province as an example, is inherited from sectionindexer
Then determine the display effect in getview, whether to display letters and where to display letters
3. Paste another provinceactivity class
OK, I pasted part of the code, and I also added comments in many key parts of the code. In the same sentence, only by implementing one by yourself can it be used conveniently in the future.
Finally put the source code: Android imitation mobile phone address book address selection function
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.