Search code examples
androidandroid-listviewandroid-listfragmentandroid-loadermanagerperformance

SherlockFragmentActivity cases performance problems with list view


Hi after extended from SherlockFragmentActivity the lists become slow. So the architecture I'm using is the following: I have:

1.SherlocFragment activity where I display the list

2.Adapter to display the list

3.AsyncTask to fetch json form the server

So I'm not using loaders or fragments or ListActivity.

I have been looking at this answer https://stackoverflow.com/a/11779941/1796624 that suggest to inflate the list in a background thread, but I don't quite understand how to do it. What will be your suggestion,do I need to use loaders to improve performance and if so please suggest a nice tutorial or should I put the list in a fragment or maybe there is a new design pattern that you can suggest to speed up things. Thanks


Solution

  • Loaders is a high level api that makes your life easier to handle database Cursor, listviews and adapters. For example, if you add new items to the database table, the loader automatically refreshes the list displaying the content from that database table.

    It is better to learn high level api's. You can learn about Loaders from android documentation. But I found these tutorial series helpful. They describe the motivation for using Loaders in a convincing way.

    However there is one catch here. You have to write a content provider to work with Loaders. To circumvent creating Content provider you can use loaderEx released by commonsware.