Best way to constantly add new data to listview

I was able to successfully write a service that downloads data from an RSS feed, parses it, and stores it in a database. I also have an activity fragment that uses the cursor loader technique to retrieve all rows of data and displays them on the screen in a horizontal listview I, removed from the Internet.

My next mission is to change the action so that I can continually request the next x number of rows each time the user scrolls closer to the end of the list and adds them to the listview . Technically, my data is small enough so that if I showed 10 lines at startup, I could just request an adapter for 20 and reset, but it seems silly to repeat the request for the same lines again.

So, in essence, my main question is: how best would I combine the contents of the listview currently populated with Cursor/CursorAdapter with the results of a new query using LoaderCallbacks ?

Second, what is the correct syntax for the SQLiteQueryBuilder limit parameter? I tried many options, although I think the line " offset, maxrows " is correct? No matter what I provide, although I always get 0 from getCount() on my cursor.

+4
source share
1 answer

Use the ArrayList of your elements inside the adapter, when you have new elements to display, just create a method to insert them into the ArrayList.

The SQL question you can find at this link http://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder.html you need to add a constraint on the buildQuery method, if that doesn't work, paste your code here

0
source

Source: https://habr.com/ru/post/1440953/


All Articles