Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Write an adapter for your list items and add a method to append new results</p> <pre><code>public class JsonListAdapter extends BaseAdapter { private List&lt;JSONObject&gt; list; public void appendList(List&lt;JSONObject&gt;pList) { if (list== null) { list= new List&lt;JSONObject&gt;(); } if (pList != null) { list.addAll(pList); notifyDataSetChanged(); } } ... } </code></pre> <p>Add a scroll listener to start the paging request</p> <pre><code>private class PagingScrollListener implements OnScrollListener { private int lastOffset = 0; @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { boolean isEndOfListReached = firstVisibleItem + visibleItemCount &gt;= totalItemCount; boolean isOffsetRequested = lastOffset &gt;= totalItemCount; if (isEndOfListReached &amp;&amp; !isOffsetRequested) { lastOffset = totalItemCount; new PagingRequest(myListAdapter).execute(lastOffset); } } ... } </code></pre> <p>Load next batch of data and update the adapter:</p> <pre><code>private static class PagingRequest extends AsyncTask&lt;Integer, Void, List&lt;JSONObject&gt; { private JsonListAdapter mAdapter; public PagingRequest(JsonListAdapter adapter) { this.mAdapter = adapter; } protected ProductList doInBackground(Integer... params) { int offset = params[0]; // PERFORM REQUEST WITH OFFSET return newResults; } protected void onPostExecute(List&lt;JSONObject&gt; result) { mAdapter.appendList(result); } } </code></pre> <p>Disclaimer: This is just the basic strategy, you still need to fill in the blanks and adapt to your code.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload