0

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

Community
  • 1
  • 1
user1796624
  • 3,665
  • 7
  • 38
  • 65
  • Probably nothing to to with sherlockFragmentActivity, probably your getView method is not opitmized as you indicate in your answer – Tobrun Jan 24 '13 at 10:07
  • Thanks for your answer, I just want to point out that I'm not extending form a listActivity or sherlockListActivity and I'm not using fragments in this case. Do you think it that using fragments will improve the performance or using a some sort of listActivity. – user1796624 Jan 24 '13 at 10:13

1 Answers1

0

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.

Supreethks
  • 597
  • 6
  • 16
  • Thanks for the link, what is your suggestion on improving performance up the app? – user1796624 Jan 24 '13 at 10:10
  • Loaders would carry out the database query in the background so the performance is definetly greater than without using one. Please go through the second part of the tutorial series that I have shared. – Supreethks Jan 24 '13 at 10:12