The user-defined view developed by Android realizes the prompt effect of a ~ Z letters in the address list [Download with demo source code]
This paper gives an example of how the user-defined view developed by Android can realize the a ~ Z letter prompt effect of address list. Share with you for your reference, as follows:
Development tool: Eclipse
Operating environment: HTC G9 Android 2.3.3
If you don't say much, look at the renderings first
In fact, a ~ Z on the left and right sides is a custom view, which directly overrides the listview.
MyLetterListView:
Then I monitor which letter my finger touches in ontouching letterchangedlistener in activity, and then let the list jump to the corresponding position,
The initial prompt box pops up:
Delay one second to make the pop-up initial prompt box invisible, that is, the initial prompt box will only be displayed for one second:
There is also the problem of parsing the man's initial Pinyin. Here is the system database I checked. There happens to be sort in it_ The key column, for example, if the name is Zhang San, then the corresponding sort_ The key is: Zhang San three, which is much easier:
If your data is not checked from the contact list, you can use a third-party jar package, pinyin4j-2.5.0.
The activity code and layout file are relatively long, so I won't post them here.
Attachment: demo source code, click here to download.
More readers interested in Android related content can view the special topics of this site: introduction and advanced tutorial of Android development, summary of Android layout skills, summary of Android view skills, summary of activity operation skills of Android programming, summary of Android operation JSON format data skills, summary of Android resource operation skills, and Android control usage summary
I hope this article will help you in Android programming.