AsynTask is adding extra item to listview
<p>I am using an pulltorefresh listview in my application.When I call pulltoRefresh I am calling AsyncTask.Before calling this I am clearing all the data in ArrayLists and set my adapter to null.
The below code shows this</p>

<pre><code>     listView.setOnRefreshListener(new OnRefreshListener() {

//          @Override
            public void onRefresh() {
                // Your code to refresh the list contents goes here
                listView.setAdapter(null);
                scroll=true;
                pic.clear();
                id.clear();
                name.clear();
                msg.clear();
                img.clear();
                profimg.clear();
                objid.clear();
                comment.clear();
                weburl.clear();
                adapter.clear();
                likes.clear();
                like_or_unlike.clear();
                 previousTotal = 0;

                  listView.removeFooterView(footerView);
//              listView.setAdapter(null);
//              scroll=true;
//              notifyDataSetChanged();
//              urlval=0;
                j=0;
                 loading = true;
                webserv="https://graph.facebook.com/me/home?access_token="+accesstoken;
                 doInBack dob=new doInBack();
                 dob.execute(); 

//               doback(webserv);
                    Log.e("hi","doback called");

                // Make sure you call listView.onRefreshComplete()
                // when the loading is done. This can be done from here or any
                // other place, like on a broadcast receive from your loading
                // service or the onPostExecute of your AsyncTask.

                // For the sake of this sample, the code will pause here to
                // force a delay when invoking the refresh

            }
        });
</code></pre>

<p>when I am calling this Asyntask,immediately one item is gets added which we cant see.I observed this in my onScrollListener class,which I used to load more data.</p>

<p>My onScrollListener class is </p>

<pre><code>     listView.setOnScrollListener(new  OnScrollListener() {

            private int threshold = 0;
//          
            public void onScrollStateChanged(AbsListView view, int scrollState) {
////                
                  if (scrollState != 0) {  
                    isScrolling = true; 
                }
                else {   
                   isScrolling = false;  
                  adapter.notifyDataSetChanged();


                }  

            }


          public void onScroll(AbsListView view, int firstVisibleItem,int visibleItemCount, int totalItemCount) 
          {     

//           public void onScrollStateChanged(AbsListView view , int scrollState)
//           {
//                  if (scrollState != 0) {  
//                      listView.getAdapter().isScrolling = true; 
//                  }
//                  else {   
//                      listView.getAdapter().isScrolling = false;  
//                      listView.getAdapter().notifyDataSetChanged();  
//                  }  
//              }  
              // TODO Auto-generated method stub

              if (loading) {
                  if (totalItemCount &gt; previousTotal) {
                    Log.e("in loading","in load");
                      loading = false;
                      previousTotal = totalItemCount;
                  }
              } 
//                   int lastInScreen = firstVisibleItem + visibleItemCount; 
//              if (!loading &amp;&amp; (totalItemCount - visibleItemCount) ==(firstVisibleItem + threshold)){
                   if (!loading &amp;&amp; (firstVisibleItem + visibleItemCount) &gt;= totalItemCount){
//                    if(((firstVisibleItem + visibleItemCount) == totalItemCount)){
//                   if (!(loading)  &amp;&amp;(totalItemCount - visibleItemCount) ==(firstVisibleItem + threshold)) {
//                clearAllResources(); 
                       System.out.println(firstVisibleItem );
                       System.out.println(visibleItemCount );
                       System.out.println(totalItemCount);
                  scroll=false;
//                  if (!(loading)  &amp;&amp;(totalItemCount - visibleItemCount) == (firstVisibleItem + threshold)) {
                       Log.v("in gridview loading more","grid load");
//                      
                       doInBack dob=new doInBack();
                       dob.execute();  
//                       doback(webserv);
                    loading = true;
                   }
              }



      });

        doInBack dob=new doInBack();
            dob.execute();     
//        doback(webserv);
        Log.e("hi","doback called");



        }
</code></pre>

<p>I really didnt understand why it is adding item temporarily on calling AsyncTask.
Help me.Thanks in advance </p>
