Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do i set limit for loading list items in Cwac-Endlessadapter when user scroll down to end of list
    text
    copied!<p>For eg:- if i load first 5 items in a list then on scrolling down load next five items</p> <p>and as it is a endlessadapter this procedure must repeat endlessly this is how i tried -->foliowing is my demoadapter code:-</p> <pre><code> public class MyDemoAdapter extends EndlessAdapter { private static int cutting_int =5; public static int batch_repeat = 0; public int check_batch = 0; private Context mcontxt; private RotateAnimation rotate = null; ArrayList&lt;DownloadOffersClass&gt; tempList = new ArrayList&lt;DownloadOffersClass&gt;(); private static int mLastOffset = 0; private ArrayList&lt;DownloadOffersClass&gt; list = new ArrayList&lt;DownloadOffersClass&gt;(); private int LIST_SIZE; public MyDemoAdapter(Context context, int textViewResourceId, ArrayList&lt;DownloadOffersClass&gt; list, int lIST_SIZE) { super(new DownloadedOffersAdapter(context, R.layout.offer_listview_item, list)); this.mcontxt = context; this.list = list; this.LIST_SIZE = lIST_SIZE; rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotate.setDuration(600); rotate.setRepeatMode(Animation.RESTART); rotate.setRepeatCount(Animation.INFINITE); } @Override protected View getPendingView(ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) mcontxt .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View row = inflater.inflate(R.layout.row, null); View child = row.findViewById(android.R.id.text1); child.setVisibility(View.GONE); child = row.findViewById(R.id.throbber); child.setVisibility(View.VISIBLE); child.startAnimation(rotate); return (row); } @Override protected boolean cacheInBackground() { SystemClock.sleep(2000); if (check_batch != batch_repeat) { tempList.clear(); int lastOffset = getLastOffset(); if (lastOffset &lt; LIST_SIZE) { int limit = lastOffset + cutting_int; for (int i = (lastOffset + 1); (i &lt;= limit &amp;&amp; i &lt; LIST_SIZE); i++) { tempList.add(list.get(i)); } setLastOffset(limit); if (limit &lt; 50) { return true; } else { return false; } } else { return false; } } else { return false; } } @Override protected void appendCachedData() { if (getWrappedAdapter().getCount() &lt; 50) { @SuppressWarnings("unchecked") DownloadedOffersAdapter a = (DownloadedOffersAdapter) getWrappedAdapter(); check_batch = check_batch + 1; Log.v("Check", " " + check_batch); for (int i = cutting_int; i &lt; cutting_int + cutting_int; i++) { a.add(list.get(i)); } } } public static void setLastOffset(int i) { mLastOffset = i; } private int getLastOffset() { return mLastOffset; } </code></pre> <p>}</p>
 

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