Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Something like this is what you might use in order to get a infinite list effect when you don't have a cursor.</p> <p>Please note this is a very rough draft since I deleted the code only relevant to my app, to help for you clarity, and for my privacy and the apps privacy. Also it may not be the best way of doing everything, but it worked the first time I wrote it (which took like 10 minutes) and worked beautifully for a very complex list, so I haven't bothered coming back to it.</p> <pre><code> class AsyncGetUpdates extends AsyncTask&lt;Void, Void, List&lt;UpdateDTO&gt;&gt; { @Override protected void onPreExecute() { showDialog(); super.onPreExecute(); } @Override protected List&lt;UpdateDTO&gt; doInBackground(Void... params) { return APIHelper.getUpdates(count); } @Override protected void onPostExecute(List&lt;UpdateDTO&gt; result) { killDialog(); isCurrentlyUpdating = false; setAdapterData(result); super.onPostExecute(result); } } public void setAdapterData(List&lt;UpdateDTO&gt; result) { killDialog(); if (this != null &amp;&amp; this.getActivity() != null) { Log.d(TAG, "setAdapterData"); if (lvUpdatesList.getAdapter() != null) { // save index and top position int index = lvUpdatesList.getFirstVisiblePosition(); View v = lvUpdatesList.getChildAt(0); int top = (v == null) ? 0 : v.getTop(); updateListAdapter = new UpdateListAdapter(this.getActivity().getLayoutInflater(), result, this); lvUpdatesList.setAdapter(updateListAdapter); lvUpdatesList.refreshDrawableState(); lvUpdatesList.setSelectionFromTop(index, top); } else { updateListAdapter = new UpdateListAdapter(this.getActivity().getLayoutInflater(), result, this); lvUpdatesList.setAdapter(updateListAdapter); lvUpdatesList.refreshDrawableState(); } } // add in a listener to know when we get to the bottom lvUpdatesList.setOnScrollListener(new OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { // we do not want to update if we already are if (isCurrentlyUpdating == false) { if (lvUpdatesList.getAdapter() != null &amp;&amp; lvUpdatesList.getAdapter().getCount() == count) { final int lastItem = firstVisibleItem + visibleItemCount; if (lastItem == totalItemCount) { isCurrentlyUpdating = true; // add to the count of views we want loaded count += 20; // start a update task new AsyncGetUpdates().execute(); } } } } }); } </code></pre> <p>Finally I would like to say that copy pasting might get you the results you want, but it will hinder you future ability. I would say study, read, learn, try, fail, and try again.</p>
    singulars
    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. 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