In this post i explain you how we get contact list and show in custom ListView android. Most app show your mobile contacts in there customize view in there app eg. WhatsApp etc. This is very simple and easy to implement in your project.

 

Code:

Step 1. Create new android project in your android studio or eclipse.

Step 2. First we need to app permission in your manifest file to read contact list. add the following line to read contact before Application tag

Step 3. Now open your activity_main.xm file inside layout folder and add ListView in it and i also add search functionality in it so i also add SearchView as shown below code.

Step 4. Now before start java coding i also create a view which i inflate in listview or a view in which we load or contact list as shown below.

Above view is very simple it contain a image view and contact person name and its contact number. I also add check box but i did not use in this but if you need it change its visibility.

Step 5. Now first i create a getter setter class in which i save my contact list info to use it further.

Step 6. Now i create custom adapter to inflate data in listview

If you want to use check box please remove comment from check box listener in above class.

Step 7. Now open your MainActivity.java class and call classes we create. In this i also use RoundImage class which is use to round your image.

Note in this i also use Async Class because if user have large contact list it will hang you application for some time so i load all contact in background.

Hope this code help in your project feel free to comment.

Happy coding 🙂 .