List not loading using onscroll listener
<p>I have a list view that retrieves data from parse.com. I have added a onscroll listener to load new list items after user reaches to every 15 items. When the user scrolls do the end of first 15 the loading footer is displayed from then on but the next list items are not getting displayed.  Don't know what the problem is?
Please help me</p>

<p>My code</p>

<pre><code>public class InterActivity extends Activity implements OnItemClickListener, OnItemLongClickListener, 
 AbsListView.OnScrollListener


 {


ListView listview;
List&lt;ParseObject&gt; ob;
ProgressDialog mProgressDialog;
FinalAdapter adapter;
 List&lt;CodeList&gt; codelist = null;
 SharedPreference shrdPreference;

 private int limit = 15;

 private final int AUTOLOAD_THRESHOLD = 4; 
 private final int MAXIMUM_ITEMS = 52;

 private View mFooterView;
 private Handler mHandler;
 private boolean mIsLoading = false;
 private boolean mMoreDataAvailable = true;
 private boolean mWasLoading = false;

View footerView;

private Runnable mAddItemsRunnable = new Runnable() { 
@Override public void run() { 

new Loadmore().execute();
mIsLoading = false;
    }
    };


@Override
public void onCreate(Bundle savedInstanceState)
{

    super.onCreate(savedInstanceState);
    setContentView(R.layout.inter_layout);
    shrdPreference = new SharedPreference();

    footerView = ((LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.loadmore, null, false);

    //Execute RemoteDataTask AsyncTask

    new RemoteDataTask().execute();
}

private class RemoteDataTask extends AsyncTask&lt;Void, Void, Void&gt; {
    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        // Create a progressdialog
        mProgressDialog = new ProgressDialog(InterActivity.this);
        // Set progressdialog title
        mProgressDialog.setTitle("Loading");
        // Set progressdialog message
        mProgressDialog.setMessage("Please wait loading ...");
        mProgressDialog.setIndeterminate(false);
        mProgressDialog.setCancelable(false);
        // Show progressdialog
        mProgressDialog.show();
    }

    @Override
    protected Void doInBackground(Void... params) {
        // Create the array
        codelist = new ArrayList&lt;CodeList&gt;();
        try {
            // Locate the class table named "Country" in Parse.com
            ParseQuery&lt;ParseObject&gt; query = new ParseQuery&lt;ParseObject&gt;(
                "InterActivity");
            // Locate the column named "ranknum" in Parse.com and order list
            // by ascending
            query.orderByAscending("_created_at");
            query.setLimit(limit);
            ob = query.find();
            for (ParseObject inter : ob) {


                map.setIntroduction((String) inter.get("intro"));
                map.setFinalCodeText((String) inter.get("codetext"));


                codelist.add(map);
            }
        } catch (ParseException e) {
            Log.e("Error", e.getMessage());
            e.printStackTrace();
        }
        return null;
    }

    @Override
    protected void onPostExecute(Void result) {
        // Locate the listview in listview_main.xml
        listview = (ListView) findViewById(R.id.inter_layoutListView);
        // Pass the results into ListViewAdapter.java
        adapter = new FinalAdapter(InterActivity.this,
                                      codelist);

        AlphaInAnimationAdapter animationAdapter = new AlphaInAnimationAdapter(adapter);
        animationAdapter.setAbsListView(listview);

        mHandler = new Handler(); 
        mFooterView = LayoutInflater.from(InterActivity.this).inflate(R.layout.loadmore, null);
        listview.addFooterView(mFooterView, null, false);

        // Binds the Adapter to the ListView
        listview.setAdapter(adapter);

        listview.setOnItemClickListener(InterActivity.this);

        listview.setOnItemLongClickListener(InterActivity.this); 
        // Close the progressdialog
        mProgressDialog.dismiss();




    }
}

@Override 
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    if(!mIsLoading &amp;&amp; mMoreDataAvailable) { 
    if (totalItemCount &gt;= MAXIMUM_ITEMS) {
        mMoreDataAvailable = false;
        listview.removeFooterView(mFooterView);
    } else if (totalItemCount - AUTOLOAD_THRESHOLD &lt;= firstVisibleItem + visibleItemCount) {
        mIsLoading = true; 
        mHandler.postDelayed(mAddItemsRunnable, 1000); 
        } 
    }
}


@Override 
public void onScrollStateChanged(AbsListView view, int scrollState) { 
// Ignore 
}

@Override
public void onStart() {
    super.onStart(); if (mWasLoading) {
        mWasLoading = false; mIsLoading = true;
        mHandler.postDelayed(mAddItemsRunnable, 1000); 
        } 
    }


@Override 
public void onStop() { 
super.onStop(); 
mHandler.removeCallbacks(mAddItemsRunnable); 
mWasLoading = mIsLoading;
mIsLoading = false; 
}

private class Loadmore extends AsyncTask&lt;Void, Void, Void&gt; {
    @Override
    protected void onPreExecute() {
        super.onPreExecute();

    }

    @Override
    protected Void doInBackground(Void... params) {
        // Create the array
        codelist = new ArrayList&lt;CodeList&gt;();
        try {
            // Locate the class table named "Country" in Parse.com
            ParseQuery&lt;ParseObject&gt; query = new ParseQuery&lt;ParseObject&gt;(
                "InterActivity");
            // Locate the column named "ranknum" in Parse.com and order list
            // by ascending
            query.orderByAscending("_created_at");
            query.setLimit(limit += 15);
            ob = query.find();
            for (ParseObject inter : ob) {



                map.setIntroduction((String) inter.get("intro"));
                map.setFinalCodeText((String) inter.get("codetext"));


                codelist.add(map);
            }
        } catch (ParseException e) {
            Log.e("Error", e.getMessage());
            e.printStackTrace();
        }
        return null;
    }

    @Override
    protected void onPostExecute(Void result) {
        int position = listview.getLastVisiblePosition();
        adapter = new FinalAdapter(InterActivity.this,
                                   codelist);

        AlphaInAnimationAdapter animationAdapter = new AlphaInAnimationAdapter(adapter);
        animationAdapter.setAbsListView(listview);


        // Binds the Adapter to the ListView
        listview.setAdapter(adapter);

        listview.setSelectionFromTop(position, 0);
    }
}
</code></pre>