Reputation: 8360
What is the best approach from a performance perspective to show a ListView with contacts and their phone numbers?
Upvotes: 7
Views: 1573
Reputation: 1502
I think CursorAdapter is the best solution.
Also make sure you watch this video http://www.youtube.com/watch?v=wDBM6wVEO70 It talks about optimizations that in my opinion are necessary to make your list scroll smoothly.
Upvotes: 0
Reputation: 5971
I think this would depend on three factors:
Your solution one would fit most of the cases though the second solution offers some advantages as well:
Solution 1:
Advantage:
Disadvantage:
If your contacts associate with a lot of data and requires some complicate inflation, you might notice a delay.
Less flexible and extensible comparing to solution 2. As discussed below.
Solution 2:
Advantage:
Disadvantage:
So yea, depending on what exactly are you are working on, choose the appropriate one.
Upvotes: 1
Reputation: 1063
I think http://www.higherpass.com/Android/Tutorials/Working-With-Android-Contacts/ will be an option. Where you can find all of the facility you want...
Upvotes: 0
Reputation: 604
In my opinion a mix solution should be better. Why this? Because you don't know or it's suppose that in most of contexts you cannot know about how and how many contacts your application will need to list. An also how many contacts are stored in the phone. If we know both answers, surely we can take the most approach solution.
So I suggest you to first bring a fix number of contacts using an in-memory array in a background thread, for example the first 20. Also if you consider that your app will perform more than one request to this service.. it will be awesome to use a sort of caching. The worst approach should be to call again and again the contacts service. Then for a request for contact #21 you can bring next 20 and so on.
So you can use the advantages of both worlds, and minimize the disadvantages too. Always depends on the application and the context that we are talking about.
Upvotes: 1