开发者

how to implement contact like A to Z list items viewer

In android there is A to Z selector on right side of the contacts. one can just select on of the alphabet and only those contacts will be displayed which are starting with that selected alphabet. I want to implement such kind of list. Any ide开发者_开发知识库a?


Here's the basic idea of what you'd need to do:

First you'll want to generate your alphabet list... you can either hard code this (Always showing A-Z) or you can try running a query from the database that will give you all of the display names, parsing the cursor to build a list of unique letters (only add a letter if its not in your list already).

After getting your list of characters you'll want to assign them to widget of your choice (either a container view with buttons or some kind of listview would work). Make sure to also have some kind of list for your contacts to be displayed in as well.

When responding to a click event of one of your letters, you'll want to run a query against the contacts database that adds something similar the following LIKE clause to your where string:

" substr(<FIELD_NAME>, 1,1) LIKE '<CLICKED LETTER>%' "

The resulting data you then just need to display in your data list.

Good luck :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜