Вопрос

I need to populate ListView with List of objects returned from my Dao object. The items get returned after 3 seconds, obviously to much time for the user to wait... I'm using BaseAdapter as the ListView adapter.

2 questions:

  1. How can get rid of the 3 seconds waiting time? Should I just retrieve the entire list of objects in a seperate worker Thread and display dialog in the meanwhile? Is there any mechanism that allows me to get the first, let's say... 20 records, display them and fetch the rest of the records while the user scrolls down the list?

  2. If I would use cursors, rather than ORMLite, the list would then query the DB as the user scrolls down the list, releasing the objects of the hidden cells and the cells themselves, and not keeping all the objects of the cursor in the memory. How can I achieve this behavior with ORMLite?

I hope I was clear enough, despite the bad English ;)

Thanks.

Это было полезно?

Решение

You might want to load the data in an AsyncTask, and display a ProgressDialog while it loads. Lot of Android apps do this.

Cannot OrmLite return a DataProvider instead of the while list? (I too wanted to look into ORM on Android but the management decided against it "Its slow", but I still badly want it)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top